diff --git a/src/main/asyncapi/network_survey_messaging.yaml b/src/main/asyncapi/network_survey_messaging.yaml index 13d7503..e728acc 100644 --- a/src/main/asyncapi/network_survey_messaging.yaml +++ b/src/main/asyncapi/network_survey_messaging.yaml @@ -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: diff --git a/src/main/proto/com/craxiom/messaging/wifi/bandwidth/wifi_bandwidth.proto b/src/main/proto/com/craxiom/messaging/wifi/bandwidth/wifi_bandwidth.proto new file mode 100644 index 0000000..60ef14f --- /dev/null +++ b/src/main/proto/com/craxiom/messaging/wifi/bandwidth/wifi_bandwidth.proto @@ -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; +} \ No newline at end of file diff --git a/src/main/proto/com/craxiom/messaging/wifi_beacon_record.proto b/src/main/proto/com/craxiom/messaging/wifi_beacon_record.proto index b56a0df..40fb511 100644 --- a/src/main/proto/com/craxiom/messaging/wifi_beacon_record.proto +++ b/src/main/proto/com/craxiom/messaging/wifi_beacon_record.proto @@ -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"; @@ -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; diff --git a/src/test/java/com/craxiom/messaging/JsonConversionTest.java b/src/test/java/com/craxiom/messaging/JsonConversionTest.java index b6591c8..a8c97d5 100644 --- a/src/test/java/com/craxiom/messaging/JsonConversionTest.java +++ b/src/test/java/com/craxiom/messaging/JsonConversionTest.java @@ -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; @@ -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"); @@ -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); @@ -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 @@ -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());