Skip to content

Commit

Permalink
Adds the bandwidth field to the Wi-Fi beacon record
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrowlands committed Jan 26, 2024
1 parent 1e933d8 commit cd3bdbe
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
14 changes: 13 additions & 1 deletion src/main/asyncapi/network_survey_messaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -779,13 +779,25 @@ components:
format: int32
minimum: 0
description: The channel on which this 802.11 frame was recorded.
example: 2
example: 6
frequencyMhz: # Defining it directly so it does not conflict with the frequency field from other messages
type: integer
format: int32
minimum: 0
description: The frequency in MHz on which this 802.11 frame was recorded.
example: 2417
bandwidth:
type: string
description: "The Wi-Fi bandwidth in MHz (one of 20, 40, 80, 80 Plus, 160, 320)."
example: "MHZ_40"
enum:
- "UNKNOWN"
- "MHZ_20"
- "MHZ_40"
- "MHZ_80"
- "MHZ_80_PLUS"
- "MHZ_160"
- "MHZ_320"
signalStrength:
$ref: '#/components/schemas/signalStrength'
snr:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Defines the Wi-Fi Bandwidth values used in the 802.11 Survey message.
*
* This protobuf definition is provided as a convenience only. See the official API documentation for the true field
* schema.
*
* It is necessary to define this enum in an individual file so that duplicate enum values can be used. This file
* specifies a different protobuf package than other enums so that the enum value scope is different than all other
* enums.
*/
syntax = "proto3";

package com.craxiom.messaging.wifi.bandwidth;

option java_multiple_files = true;
option java_package = "com.craxiom.messaging.wifi";

enum WifiBandwidth {
UNKNOWN = 0;
MHZ_20 = 1;
MHZ_40 = 2;
MHZ_80 = 3;
MHZ_80_PLUS = 4;
MHZ_160 = 5;
MHZ_320 = 6;
}
2 changes: 2 additions & 0 deletions src/main/proto/com/craxiom/messaging/wifi_beacon_record.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import "com/craxiom/messaging/wifi/akmsuite/akm_suite.proto";
import "com/craxiom/messaging/wifi/encryptiontype/encryption_type.proto";
import "com/craxiom/messaging/wifi/nodetype/node_type.proto";
import "com/craxiom/messaging/wifi/standard/standard.proto";
import "com/craxiom/messaging/wifi/bandwidth/wifi_bandwidth.proto";

option java_multiple_files = true;
option java_package = "com.craxiom.messaging";
Expand Down Expand Up @@ -59,6 +60,7 @@ message WifiBeaconRecordData {
com.craxiom.messaging.wifi.encryptiontype.EncryptionType encryptionType = 20;
google.protobuf.BoolValue wps = 21;
google.protobuf.BoolValue passpoint = 28;
com.craxiom.messaging.wifi.bandwidth.WifiBandwidth bandwidth = 29;

google.protobuf.Int32Value channel = 22;
google.protobuf.Int32Value frequencyMhz = 23;
Expand Down
13 changes: 5 additions & 8 deletions src/test/java/com/craxiom/messaging/JsonConversionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
import com.craxiom.messaging.phonestate.Domain;
import com.craxiom.messaging.phonestate.NetworkType;
import com.craxiom.messaging.phonestate.SimState;
import com.craxiom.messaging.wifi.AkmSuite;
import com.craxiom.messaging.wifi.CipherSuite;
import com.craxiom.messaging.wifi.EncryptionType;
import com.craxiom.messaging.wifi.NodeType;
import com.craxiom.messaging.wifi.ServiceSetType;
import com.craxiom.messaging.wifi.Standard;
import com.craxiom.messaging.wifi.*;
import com.google.protobuf.BoolValue;
import com.google.protobuf.ByteString;
import com.google.protobuf.DoubleValue;
Expand Down Expand Up @@ -554,7 +549,7 @@ public void testNrRecordFromJson()
@Test
public void testWifiBeaconToJson()
{
final String expectedJson = "{\"version\":\"0.13.0\",\"messageType\":\"WifiBeaconRecord\",\"data\":{\"deviceSerialNumber\":\"1234\",\"deviceName\":\"WiFi Pixel\",\"deviceTime\":\"1996-12-19T16:39:57-08:00\",\"latitude\":51.470334,\"longitude\":-0.486594,\"altitude\":13.3,\"missionId\":\"Survey1 20200724-154325\",\"recordNumber\":1,\"accuracy\":40,\"sourceAddress\":\"68:7F:74:B0:14:98\",\"destinationAddress\":\"68:7F:74:B0:14:22\",\"bssid\":\"68:7F:74:B0:14:98\",\"beaconInterval\":100,\"serviceSetType\":\"BSS\",\"ssid\":\"My Wi-Fi Network\",\"supportedRates\":\"1; 2; 5.5; 11; 18; 24; 36; 54\",\"extendedSupportedRates\":\"6; 9; 12; 48\",\"cipherSuites\":[\"TKIP\",\"CCMP\"],\"akmSuites\":[\"OPEN\"],\"encryptionType\":\"WPA_WPA2\",\"wps\":true,\"channel\":2,\"frequencyMhz\":2417,\"signalStrength\":-58.5,\"snr\":26.7,\"nodeType\":\"AP\",\"standard\":\"IEEE80211N\",\"passpoint\":true,\"heading\":-32.7,\"pitch\":0.1,\"roll\":0.2,\"fieldOfView\":10.0,\"receiverSensitivity\":30.0}}";
final String expectedJson = "{\"version\":\"0.13.0\",\"messageType\":\"WifiBeaconRecord\",\"data\":{\"deviceSerialNumber\":\"1234\",\"deviceName\":\"WiFi Pixel\",\"deviceTime\":\"1996-12-19T16:39:57-08:00\",\"latitude\":51.470334,\"longitude\":-0.486594,\"altitude\":13.3,\"missionId\":\"Survey1 20200724-154325\",\"recordNumber\":1,\"accuracy\":40,\"sourceAddress\":\"68:7F:74:B0:14:98\",\"destinationAddress\":\"68:7F:74:B0:14:22\",\"bssid\":\"68:7F:74:B0:14:98\",\"beaconInterval\":100,\"serviceSetType\":\"BSS\",\"ssid\":\"My Wi-Fi Network\",\"supportedRates\":\"1; 2; 5.5; 11; 18; 24; 36; 54\",\"extendedSupportedRates\":\"6; 9; 12; 48\",\"cipherSuites\":[\"TKIP\",\"CCMP\"],\"akmSuites\":[\"OPEN\"],\"encryptionType\":\"WPA_WPA2\",\"wps\":true,\"channel\":2,\"frequencyMhz\":2417,\"signalStrength\":-58.5,\"snr\":26.7,\"nodeType\":\"AP\",\"standard\":\"IEEE80211N\",\"passpoint\":true,\"bandwidth\":\"MHZ_160\",\"heading\":-32.7,\"pitch\":0.1,\"roll\":0.2,\"fieldOfView\":10.0,\"receiverSensitivity\":30.0}}";

final WifiBeaconRecord.Builder recordBuilder = WifiBeaconRecord.newBuilder();
recordBuilder.setVersion("0.13.0");
Expand Down Expand Up @@ -590,6 +585,7 @@ public void testWifiBeaconToJson()
dataBuilder.setPasspoint(BoolValue.newBuilder().setValue(true).build());
dataBuilder.setChannel(Int32Value.newBuilder().setValue(2).build());
dataBuilder.setFrequencyMhz(Int32Value.newBuilder().setValue(2417).build());
dataBuilder.setBandwidth(WifiBandwidth.MHZ_160);
dataBuilder.setSignalStrength(FloatValue.newBuilder().setValue(-58.5f).build());
dataBuilder.setSnr(FloatValue.newBuilder().setValue(26.7f).build());
dataBuilder.setNodeType(NodeType.AP);
Expand All @@ -612,7 +608,7 @@ public void testWifiBeaconToJson()
@Test
public void testWifiBeaconFromJson()
{
final String inputJson = "{\"version\":\"0.13.0\",\"messageType\":\"WifiBeaconRecord\",\"data\":{\"deviceSerialNumber\":\"1234\",\"deviceName\":\"WiFi Pixel\",\"deviceTime\":\"1996-12-19T16:39:57-08:00\",\"latitude\":51.470334,\"longitude\":-0.486594,\"altitude\":13.3,\"missionId\":\"Survey1 20200724-154325\",\"recordNumber\":1,\"accuracy\":40,\"sourceAddress\":\"68:7F:74:B0:14:98\",\"destinationAddress\":\"68:7F:74:B0:14:22\",\"bssid\":\"68:7F:74:B0:14:98\",\"beaconInterval\":100,\"serviceSetType\":\"BSS\",\"ssid\":\"My Wi-Fi Network\",\"supportedRates\":\"1; 2; 5.5; 11; 18; 24; 36; 54\",\"extendedSupportedRates\":\"6; 9; 12; 48\",\"cipherSuites\":[\"TKIP\",\"CCMP\"],\"akmSuites\":[\"OPEN\"],\"encryptionType\":\"WPA_WPA2\",\"wps\":true,\"channel\":2,\"frequencyMhz\":2417,\"signalStrength\":-58.5,\"snr\":26.7,\"nodeType\":\"AP\",\"standard\":\"IEEE80211N\",\"passpoint\":true,\"heading\":-32.7,\"pitch\":0.1,\"roll\":0.2,\"fieldOfView\":10.0,\"receiverSensitivity\":30.0}}";
final String inputJson = "{\"version\":\"0.13.0\",\"messageType\":\"WifiBeaconRecord\",\"data\":{\"deviceSerialNumber\":\"1234\",\"deviceName\":\"WiFi Pixel\",\"deviceTime\":\"1996-12-19T16:39:57-08:00\",\"latitude\":51.470334,\"longitude\":-0.486594,\"altitude\":13.3,\"missionId\":\"Survey1 20200724-154325\",\"recordNumber\":1,\"accuracy\":40,\"sourceAddress\":\"68:7F:74:B0:14:98\",\"destinationAddress\":\"68:7F:74:B0:14:22\",\"bssid\":\"68:7F:74:B0:14:98\",\"beaconInterval\":100,\"serviceSetType\":\"BSS\",\"ssid\":\"My Wi-Fi Network\",\"supportedRates\":\"1; 2; 5.5; 11; 18; 24; 36; 54\",\"extendedSupportedRates\":\"6; 9; 12; 48\",\"cipherSuites\":[\"TKIP\",\"CCMP\"],\"akmSuites\":[\"OPEN\"],\"encryptionType\":\"WPA_WPA2\",\"wps\":true,\"channel\":2,\"frequencyMhz\":2417,\"signalStrength\":-58.5,\"snr\":26.7,\"nodeType\":\"AP\",\"standard\":\"IEEE80211N\",\"passpoint\":true,\"bandwidth\":\"MHZ_160\",\"heading\":-32.7,\"pitch\":0.1,\"roll\":0.2,\"fieldOfView\":10.0,\"receiverSensitivity\":30.0}}";

final WifiBeaconRecord.Builder builder = WifiBeaconRecord.newBuilder();
try
Expand Down Expand Up @@ -658,6 +654,7 @@ public void testWifiBeaconFromJson()
assertTrue(data.getPasspoint().getValue());
assertEquals(2, data.getChannel().getValue());
assertEquals(2417, data.getFrequencyMhz().getValue());
assertEquals(WifiBandwidth.MHZ_160, data.getBandwidth());
assertEquals(-58.5, data.getSignalStrength().getValue());
assertEquals(26.7, data.getSnr().getValue(), FLOAT_TOLERANCE);
assertEquals(NodeType.AP, data.getNodeType());
Expand Down

0 comments on commit cd3bdbe

Please sign in to comment.