diff --git a/wnt/protocol_buffers_files/commons.proto b/wnt/protocol_buffers_files/commons.proto index ee223ce..691d2a1 100644 --- a/wnt/protocol_buffers_files/commons.proto +++ b/wnt/protocol_buffers_files/commons.proto @@ -7,8 +7,6 @@ */ syntax="proto2"; -import "nanopb.proto"; - package com.wirepas.proto.wnt; enum BaseRole { @@ -18,6 +16,16 @@ enum BaseRole { ROLE_UNKNOWN = 255; } +enum MessageSendingType { + MESSAGE_SENDING_TYPE_INSTANT = 1; + MESSAGE_SENDING_TYPE_DISTRIBUTED = 2; +} + +enum SelectionType { + SELECTION_TYPE_NETWORK = 1; + SELECTION_TYPE_SINK = 2; +} + message FullRole { optional BaseRole base_role = 1; optional bool cb_mac = 2; // True = low latency, false = low energy @@ -26,15 +34,10 @@ message FullRole { } message AppConfigData { - enum Type { - NETWORK = 1; - SINK = 2; - } - optional uint32 interval = 1; // Diagnostics interval in seconds optional uint32 sequence = 2; - optional bytes app_config = 3 [(nanopb).max_size = 1024]; + optional bytes app_config = 3; optional uint32 max_length = 4; // Maximum length of the app config optional bool is_override_on = 5; // WNT backend will override appconfig if it is changed outside of WNT - optional Type type = 6; + optional SelectionType selection_type = 6; } diff --git a/wnt/protocol_buffers_files/internal.proto b/wnt/protocol_buffers_files/internal.proto index d09d27f..db9717d 100644 --- a/wnt/protocol_buffers_files/internal.proto +++ b/wnt/protocol_buffers_files/internal.proto @@ -7,7 +7,6 @@ */ syntax="proto2"; -import "nanopb.proto"; import "commons.proto"; package com.wirepas.proto.wnt; @@ -70,6 +69,9 @@ message BackendMessage { // Used for backend internal messaging RTSituationSendPositioningData = 9; RTSituationComponentInformation = 10; RTSituationQueryNodeMetadata = 11; + RTSituationQueryNetworkMetadata = 12; + RTSituationQueryBuildingAndFloorPlanMetadata = 13; + RTSituationQueryAreaMetadata = 14; } optional MessageType message = 1; @@ -88,6 +90,7 @@ message OnlineStatus { // Node online status optional Status status = 1; optional uint32 update_time = 2; // Epoch optional uint32 last_time_series_write = 3; // Epoch + optional Status previous_status = 4; optional bool is_sink_online_in_gateway = 10; } @@ -140,6 +143,7 @@ message Network { optional uint32 id = 1; optional string name = 2; optional uint32 update_time = 3; + optional bool is_delete_nodes = 4; } message User { @@ -262,12 +266,12 @@ message MetadataUpdateMessage { } message SinkPseudoIdMap { - optional string pseudo_id = 1 [(nanopb).max_size = 1024]; + optional string pseudo_id = 1; optional uint32 network_id = 10; optional uint32 address = 11; // Node id - optional string gateway_id = 12 [(nanopb).max_size = 128]; - optional string gateway_sink_id = 13 [(nanopb).max_size = 128]; + optional string gateway_id = 12; + optional string gateway_sink_id = 13; optional AppConfigData app_config = 20; optional uint32 stored_scratchpad_sequence = 21; diff --git a/wnt/protocol_buffers_files/message.proto b/wnt/protocol_buffers_files/message.proto index a48b224..55fbdaa 100644 --- a/wnt/protocol_buffers_files/message.proto +++ b/wnt/protocol_buffers_files/message.proto @@ -24,13 +24,17 @@ message Neighbor { optional float radio_power_dB = 3; enum NeighborType { MEMBER = 1; - SYNC_CLUSTER = 2; - ASSOCIATED_CLUSTER = 3; + SYNC_CLUSTER = 2; // Alternative route + ASSOCIATED_CLUSTER = 3; // Next hop + UNSYNCED = 4; // Heard from scan/SNDP NEIGHBOR_TYPE_UNKNOWN = 255; } optional NeighborType neighbor_type = 4; optional float rssi_dBm = 5; optional bool no_neighbors = 6; // This is special value to create 1-size list when no neighbors exist + optional uint32 cluster_channel = 7; + optional uint32 amount_of_cluster_beacon_reception_attempts = 8; + optional uint32 amount_of_failed_cluster_beacon_reception_attempts = 9; } message CostInfo { @@ -60,11 +64,15 @@ enum StackProfile { PROFILE_UNKNOWN = 255; } +message CalculatedValuesFromDiagnostics { + optional float low_energy_transmission_load_percentage = 1; +} + message DiagnosticsData { // This message is general purpose container. // This does NOT distinguish different types of diagnostics packets! // Info currently sent in neighbor diagnostics - repeated Neighbor neighbors = 1 [(nanopb).max_count = 30]; + repeated Neighbor neighbors = 1 [(nanopb).max_count = 32]; // Info currently sent in node diagnostics optional float access_cycle_ms = 2; @@ -76,23 +84,17 @@ message DiagnosticsData { optional float max_buffer_usage = 8; // Percentage optional float average_buffer_usage = 9; // Percentage optional uint32 mem_alloc_fails = 10; - repeated float buf_delay_ms = 11 [packed=true, (nanopb).max_count = 16]; // By qos + // WM FW 3.x not supported anymore - repeated float buf_delay_ms = 11 [packed=true, (nanopb).max_count = 2]; // By qos optional uint32 scans = 12; - repeated float dl_average_ms = 13 [packed=true, (nanopb).max_count = 16]; // By qos - repeated float dl_minimum_ms = 14 [packed=true, (nanopb).max_count = 16]; // By qos - repeated float dl_maximum_ms = 15 [packed=true, (nanopb).max_count = 16]; // By qos - repeated uint32 dl_samples = 16 [packed=true, (nanopb).max_count = 16]; // By qos + // WM FW 3.x not supported anymore - repeated float dl_average_ms = 13 [packed=true, (nanopb).max_count = 2]; // By qos + // WM FW 3.x not supported anymore - repeated float dl_minimum_ms = 14 [packed=true, (nanopb).max_count = 2]; // By qos + // WM FW 3.x not supported anymore - repeated float dl_maximum_ms = 15 [packed=true, (nanopb).max_count = 2]; // By qos + // WM FW 3.x not supported anymore - repeated uint32 dl_samples = 16 [packed=true, (nanopb).max_count = 2]; // By qos + // Not valid for WM version >= 5.0 as there is one combined value for dropped packets - repeated uint32 dropped = 17 [packed=true, (nanopb).max_count = 16]; // By qos + repeated uint32 dropped = 17 [packed=true, (nanopb).max_count = 2]; // By qos optional uint32 sink_address = 49; - repeated CostInfo cost = 18 [(nanopb).max_count = 16]; // By qos - // If WM version >= 4.0 values below are not valid - // float buf_delay_ms = 11 - // float dl_average_ms = 13; - // float dl_minimum_ms = 14; - // float dl_maximum_ms = 15; - // uint32 dl_samples = 16; - + repeated CostInfo cost = 18 [(nanopb).max_count = 2]; // By qos enum Events { ROLE_NO_EVENTS = 0; // This is special value to create 1-size list when no events occurred ROLE_CHANGE_TO_SUBNODE = 8; @@ -139,32 +141,21 @@ message DiagnosticsData { optional float duty_cycle = 20; // Percentage optional uint32 antenna = 21; - // Info currently in traffic diagnostics, not sent by subnodes - optional uint32 access_cycles = 22; + // WM FW 3.x not supported anymore - optional uint32 access_cycles = 22; optional float cluster_channel_MHz = 23; optional float channel_reliability = 24; // Percentage - optional uint32 rx_amount = 25; - optional uint32 tx_amount = 26; + // WM FW 3.x not supported anymore - optional uint32 rx_amount = 25; + // WM FW 3.x not supported anymore - optional uint32 tx_amount = 26; optional float aloha_rx_ratio = 27; // Percentage - optional float reserved_rx_success_ratio = 28; // Percentage - optional float data_rx_ratio = 47; // Percentage - optional float rx_duplicate_ratio = 29; // Percentage - optional float cca_success_ratio = 30; // Percentage - optional float broadcast_ratio = 31; // Percentage - optional float failed_unicast_ratio = 32; // Percentage + // WM FW 3.x not supported anymore - optional float reserved_rx_success_ratio = 28; // Percentage + // WM FW 3.x not supported anymore - optional float data_rx_ratio = 47; // Percentage + // WM FW 3.x not supported anymore - optional float rx_duplicate_ratio = 29; // Percentage + // WM FW 3.x not supported anymore - optional float cca_success_ratio = 30; // Percentage + // WM FW 3.x not supported anymore - optional float broadcast_ratio = 31; // Percentage + // WM FW 3.x not supported anymore - optional float failed_unicast_ratio = 32; // Percentage optional float max_reserved_slot_usage = 33; // Percentage optional float avg_reserved_slot_usage = 48; // Percentage optional float max_aloha_slot_usage = 34; // Percentage - // If WM version >= 4.0 values below are not valid - // uint32 access_cycles = 22; - // uint32 rx_amount = 25; - // uint32 tx_amount = 26; - // float aloha_rx_ratio = 27; - // float reserved_rx_success_ratio = 28; - // float data_rx_ratio = 47; - // float rx_duplicate_ratio = 29; - // float cca_success_ratio = 30; - // float failed_unicast_ratio = 32; // Info currently in boot diagnostics optional uint32 boot_count = 35; @@ -182,6 +173,13 @@ message DiagnosticsData { EFR32XG12_1024KB_128KB = 5; NRF52840_1024KB_256KB = 6; EFR32XG12_512KB_64KB = 7; + EFR32XG13_512KB = 8; + NRF52833 = 9; + EFR32XG21 = 10; + EFR32XG22 = 11; + BGM210PA22JIA = 12; + BGM220PC22HNA = 13; + BGM220SC22HNA = 14; HWMAGIC_UNKNOWN = 255; } @@ -245,21 +243,63 @@ message DiagnosticsData { enum TraceType { NODE_DIAGNOSTICS = 1; - BOOT_DIAGNOSTICS = 7; + NEIGHBOR_DIAGNOSTICS = 2; + SCAN_DIAGNOSTICS = 3; + BOOT_DIAGNOSTICS = 4; + BOOT_DIAGNOSTICS_WM_FW_5_0 = 7; } optional TraceType trace_type = 86; + optional uint32 packet_sequence_number = 87; + + // New in 5.1 + optional uint32 cluster_channel = 88; + optional uint32 sleep_time_s = 89; + enum BootReason + { + NORMAL_POWER_ON_RESET_STARTUP = 0; + REBOOT_REQUESTED_AS_PART_OF_NORMAL_OPERATION = 1; + SOFTWARE_ASSERT_FAILURE = 2; + MCU_FAULT = 3; + WATCHDOG_RESET = 4; + UNKNOWN_RESET_REASON = 5; + } + + optional BootReason boot_reason = 90; + optional int32 rx_gain = 91; + repeated int32 tx_powers = 92 [packed=true, (nanopb).max_count = 16]; + optional uint32 scratchpad_transfers = 93; + + enum InstallationQualityError + { + NO_ROUTE_TO_SINK = 0; + NOT_ENOUGH_NEIGHBORS = 1; + BAD_RSSI = 2; + } + + optional float installation_quality = 94; + // Max_count should be the same as InstallationQualityError enum item count + repeated InstallationQualityError installation_quality_errors = 95 [packed=true, (nanopb).max_count = 3]; + optional uint32 dropped_unack_broadcast_packets = 96; + optional uint32 unacknowledged_broadcast_transmissions_channel_count = 97; + optional int32 wide_band_noise_rssi_correction_dBm = 98; + optional float network_channel_packet_error_rate_percent = 99; + + // Old value before 5.1 optional uint64 boot_diagnostics_tx_time_ms_epoch = 100; + + // New in 5.1 continues + optional int32 cca_limit_dBm = 101; } message RxData { optional uint32 source_endpoint = 2; optional uint32 destination_endpoint = 4; optional uint32 qos = 5 [default = 0]; - optional bytes payload = 7 [(nanopb).max_size = 1024]; + optional bytes payload = 7; - // If WM version >= 4.0 QoS is divided to QoS and Hop count + // If WM FW version >= 4.0 QoS is divided to QoS and Hop count optional uint32 hop_count = 10; } @@ -311,8 +351,8 @@ message GatewayHeartbeat { message GatewayInfo { optional uint32 current_time_s_epoch = 1; - optional string model = 2 [(nanopb).max_size = 256]; - optional string version = 3 [(nanopb).max_size = 64]; + optional string model = 2; + optional string version = 3; optional uint32 api_version = 4; } @@ -338,13 +378,14 @@ message NodeMessage { optional uint32 source_end_point = 3; optional uint32 destination_end_point = 4; optional uint32 qos = 5; - optional bytes payload = 6 [(nanopb).max_size = 1024]; + optional bytes payload = 6; } message GetScratchpadStatus { optional uint32 network_id = 1; - optional uint32 rerun_interval_s = 2; + optional uint32 resend_interval_s = 2; optional bool is_close = 3; + optional bool is_sink_only = 4; } enum ScratchpadType { @@ -367,6 +408,15 @@ enum ScratchpadWriteStatus { SCRATCHPAD_WRITE_STATUS_UNKNOWN = 9; } +enum ScratchpadAction { + SCRATCHPAD_ACTION_UNKNOWN = 0; + SCRATCHPAD_ACTION_NO_OTAP = 1; + SCRATCHPAD_ACTION_PROPAGATE_ONLY = 2; + SCRATCHPAD_ACTION_PROPAGATE_AND_PROCESS = 3; + SCRATCHPAD_ACTION_PROPAGATE_AND_PROCESS_WITH_DELAY = 4; + SCRATCHPAD_ACTION_LEGACY = 5; +} + message ScratchpadStatus { optional bool is_continuous_query_on = 1; optional uint64 tx_time_ms_epoch = 2; // Not updated when is_continuous_query_on changes @@ -394,6 +444,17 @@ message ScratchpadStatus { optional uint32 processed_application_version_minor = 45; optional uint32 processed_application_version_maintenance = 46; optional uint32 processed_application_version_devel = 47; + + optional ScratchpadAction scratchpad_action = 60; + optional uint32 target_sequence = 61; + optional uint32 target_crc = 62; + optional uint32 target_delay_minutes = 63; + optional uint32 remaining_time_minutes = 64; +} + +message SetScratchpadAction { + optional uint32 network_id = 1; + optional ScratchpadAction scratchpad_action = 2; } // This is the main message that base of every Protocol Buffer message @@ -401,7 +462,7 @@ message Message { // Message overhead repeated uint32 id = 1 [packed=true]; // Message ID. Not kept as uint64! optional uint32 network_id = 2; - optional string gateway_id = 3 [(nanopb).max_size = 256]; + optional string gateway_id = 3; optional uint64 tx_time = 4; // Generation time of the message: epoch ms optional uint64 rx_time = 5; // Reception time of the message; epoch ms @@ -420,7 +481,7 @@ message Message { optional uint32 channel_map = 57; optional uint32 network_channel = 58; optional bool security_enabled = 59; - repeated ChannelIdToFreqMap channel_info = 60 [(nanopb).max_count = 256]; + repeated ChannelIdToFreqMap channel_info = 60; optional AppConfigResponse app_config_response = 61; optional AccessCycleLimits access_cycle_limits = 62; optional GatewayInfo gateway_info = 63; @@ -435,7 +496,7 @@ message Message { optional RTSituationMetadata rtsituation_metadata = 74; optional BackendHeartbeat backend_heartbeat = 75; optional MetadataUpdateMessage metadata_update_message = 76; - repeated SinkPseudoIdMap sink_pseudo_id_map = 77 [(nanopb).max_count = 4096]; + repeated SinkPseudoIdMap sink_pseudo_id_map = 77; optional BackendComponentStatus backend_component_status = 78; // Remote API procedures @@ -443,19 +504,23 @@ message Message { optional RemoteApiResponse remoteapi_response = 81; // Messages to network - repeated NodeMessage node_messages = 90 [(nanopb).max_count = 8]; - repeated GetScratchpadStatus get_scratchpad_status = 91 [(nanopb).max_count = 8]; + repeated NodeMessage node_messages = 90; + repeated GetScratchpadStatus get_scratchpad_status = 91; // OTAP - optional LoadScratchpad load_scratchpad = 100; - optional OTAPResponse otap_response = 101; + optional SetOTAPState set_otap_state = 100; + optional SetOTAPStateResponse set_otap_state_response = 101; + optional SetScratchpadAction set_scratchpad_action = 102; // Positioning optional com.wirepas.proto.wpe.MeshData positioning_mesh_data = 130; optional com.wirepas.proto.wpe.Status positioning_status_data = 131; + + // Other + optional CalculatedValuesFromDiagnostics calculated_values_from_diagnostics = 160; } -// This is container of multiple messages at the same time ( Not used at the moment ) +// This is container of multiple messages at the same time message MessageCollection { - repeated Message message = 1 [(nanopb).max_count = 256]; + repeated Message message_collection = 1; } diff --git a/wnt/protocol_buffers_files/otap.proto b/wnt/protocol_buffers_files/otap.proto index 4a70e37..2e105ed 100644 --- a/wnt/protocol_buffers_files/otap.proto +++ b/wnt/protocol_buffers_files/otap.proto @@ -7,24 +7,55 @@ */ syntax="proto2"; -import "nanopb.proto"; +import "commons.proto"; package com.wirepas.proto.wnt; -message LoadScratchpad { - optional uint32 network_id = 1; - optional bytes scratchpad_bytes = 2 [(nanopb).max_size = 1048576]; // 1MB - optional uint32 rerun_interval_s = 3; - optional bool is_cancel = 4; - optional bool is_close = 5; - optional bool is_sink_only = 6; +enum OTAPState { + OTAP_STATE_NONE = 0; + OTAP_STATE_WAIT_FOR_START = 1; // For UI only + OTAP_STATE_SCRATCHPAD_STATUS_QUERY = 2; + OTAP_STATE_LOAD_SCRATCHPAD = 3; + OTAP_STATE_ACTIVATE = 4; + OTAP_STATE_NPAD_LOAD_AND_ACTIVATE = 5; + OTAP_STATE_WAIT_FOR_ACTIVATION = 6; // For backend only + OTAP_STATE_CLOSE = 7; +} + +enum OTAPMethod { + OTAP_METHOD_NONE = 0; + OTAP_METHOD_LEGACY = 1; + OTAP_METHOD_NPAD = 2; +} + +enum OTAPNPADDelay { + OTAP_NPAD_DELAY_NONE = 0; + OTAP_NPAD_DELAY_TEN_MINUTES = 1; + OTAP_NPAD_DELAY_THIRTY_MINUTES = 2; + OTAP_NPAD_DELAY_ONE_HOUR = 3; + OTAP_NPAD_DELAY_SIX_HOURS = 4; + OTAP_NPAD_DELAY_ONE_DAY = 5; + OTAP_NPAD_DELAY_TWO_DAYS = 6; + OTAP_NPAD_DELAY_FIVE_DAYS = 7; +} + +message SetOTAPState { + optional OTAPState state = 1; + optional uint32 network_id = 2; + optional bytes scratchpad_bytes = 3; + optional uint32 resend_interval_s = 4; + optional bool is_sink_only = 5; + optional uint32 sequence_number = 6; + optional OTAPMethod method = 7; + optional uint32 scratchpad_crc = 8; + optional OTAPNPADDelay npad_delay = 9; optional uint32 start_time_s_epoch = 10; - optional uint32 activation_time_s_epoch = 11; - optional uint32 cancel_time_s_epoch = 12; + optional uint32 loading_time_s_epoch = 11; + optional uint32 activation_time_s_epoch = 12; } -message OTAPResponse { +message SetOTAPStateResponse { enum OTAPResponseId { // Same as gateway ErrorCode OK = 0; INTERNAL_ERROR = 1; @@ -43,7 +74,7 @@ message OTAPResponse { INVALID_DATA_PAYLOAD = 14; INVALID_SCRATCHPAD = 15; INVALID_SCRATCHPAD_SIZE = 16; - INVLAID_SEQUENCE_NUMBER = 17; + INVALID_SEQUENCE_NUMBER = 17; INVALID_REBOOT_DELAY = 18; INVALID_DIAG_INTERVAL = 19; INVALID_APP_CONFIG = 20; @@ -54,12 +85,12 @@ message OTAPResponse { INVALID_MAX_HOP_COUNT = 25; } - optional uint32 start_time_s_epoch = 1; - optional uint32 activation_time_s_epoch = 2; - optional uint32 cancel_time_s_epoch = 3; + optional OTAPState state = 1; - optional uint32 new_scratchpad_sequence = 10; + optional uint32 start_time_s_epoch = 2; + optional uint32 activation_time_s_epoch = 3; - optional OTAPResponseId load_scratchpad_response = 20; - optional OTAPResponseId activate_scratchpad_response = 21; + optional OTAPResponseId load_scratchpad_response = 10; + optional OTAPResponseId activate_scratchpad_response = 11; + optional uint32 load_scratchpad_response_time_s_epoch = 12; } diff --git a/wnt/protocol_buffers_files/remote_api.proto b/wnt/protocol_buffers_files/remote_api.proto index b37561b..26311e6 100644 --- a/wnt/protocol_buffers_files/remote_api.proto +++ b/wnt/protocol_buffers_files/remote_api.proto @@ -7,14 +7,13 @@ */ syntax="proto2"; -import "nanopb.proto"; import "commons.proto"; package com.wirepas.proto.wnt; message RemoteApiRequest { // To which devices this request stands for - repeated uint32 addresses = 1 [(nanopb).max_count = 1024]; + repeated uint32 addresses = 1; // Sink address to use when sendind data via unicast optional uint32 sink_address = 2; @@ -26,8 +25,8 @@ message RemoteApiRequest { optional uint32 network_address = 13; optional uint32 network_channel = 14; - optional bytes cipher_key = 15 [(nanopb).max_size = 32]; - optional bytes authentication_key = 16 [(nanopb).max_size = 32]; + optional bytes cipher_key = 15; + optional bytes authentication_key = 16; optional uint32 channel_map = 17; optional uint32 node_address = 18; } @@ -39,12 +38,13 @@ enum RemoteApiRequestType { // This is a collection of remote messages currently undergoing message RemoteApiRequestCollection { - optional string id = 1 [(nanopb).max_size = 64]; // UUID + optional string id = 1; // UUID optional RemoteApiRequestType type = 2; - repeated RemoteApiRequest messages = 3 [(nanopb).max_count = 32]; - optional uint32 rerun_interval_s = 4; // Interval to resend the requests + repeated RemoteApiRequest messages = 3; + optional uint32 resend_interval_s = 4; // Interval to resend the requests optional bool is_cancel = 5; optional bool is_close = 6; + optional MessageSendingType message_sending_type = 7; optional uint32 start_time_s_epoch = 10; optional uint32 activation_time_s_epoch = 11; diff --git a/wrappers/python/examples/wnt/applicationconfiguration.py b/wrappers/python/examples/wnt/applicationconfiguration.py old mode 100755 new mode 100644 index c81f980..63ffea1 --- a/wrappers/python/examples/wnt/applicationconfiguration.py +++ b/wrappers/python/examples/wnt/applicationconfiguration.py @@ -183,11 +183,15 @@ def authentication_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Authentication socket error: {0}".format(error)) - def authentication_on_close(self, _websocket) -> None: + def authentication_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the authentication connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.info("Authentication socket close") @@ -218,11 +222,15 @@ def metadata_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Metadata socket error: {0}".format(error)) - def metadata_on_close(self, _websocket) -> None: + def metadata_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the metadata connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.warning("Metadata socket close") @@ -273,22 +281,57 @@ def realtime_situation_on_message(self, _websocket, message: str) -> None: self.state == self.state.WAIT_FOR_APPLICATION_CONFIGURATION or self.state == self.State.SET_APPLICATION_CONFIGURATION ): - wnt_message = wnt_proto.Message() - wnt_message.ParseFromString(message) - - if wnt_message.HasField("app_config"): - app_config_string = str( - binascii.hexlify(wnt_message.app_config.app_config), "utf-8" - ) - self.logger.info( - "App config message received from {}:{} with diagnostics " - "interval {} and application data {}".format( - wnt_message.network_id, - wnt_message.source_address, - wnt_message.app_config.interval, - app_config_string, - ) - ) + wnt_message_collection = wnt_proto.MessageCollection() + wnt_message_collection.ParseFromString(message) + if wnt_message_collection.message_collection: + for wnt_message in wnt_message_collection.message_collection: + if wnt_message.HasField("app_config"): + app_config_string = "" + app_config_sequence = "" + app_config_max_length = "" + app_config_interval = "" + app_config_is_override_on = "" + app_config_selection_type = "" + if wnt_message.app_config.HasField("app_config"): + app_config_string = str( + binascii.hexlify(wnt_message.app_config.app_config), + "utf-8", + ) + if wnt_message.app_config.HasField("sequence"): + app_config_sequence = str(wnt_message.app_config.sequence) + if wnt_message.app_config.HasField("interval"): + app_config_interval = str(wnt_message.app_config.interval) + if wnt_message.app_config.HasField("is_override_on"): + app_config_is_override_on = str( + wnt_message.app_config.is_override_on + ) + if wnt_message.app_config.HasField("selection_type"): + app_config_selection_type = str( + wnt_message.app_config.selection_type + ) + if wnt_message.app_config.HasField("max_length"): + app_config_max_length = str( + wnt_message.app_config.max_length + ) + + self.logger.info( + "App config message received from {}:{} with:\n" + " sequence: {}\n" + " diagnostics interval: {}\n" + " is_override_on: {}\n" + " selection type: {}\n" + " max length: {}\n" + " application data: {}".format( + wnt_message.network_id, + wnt_message.source_address, + app_config_sequence, + app_config_interval, + app_config_is_override_on, + app_config_selection_type, + app_config_max_length, + app_config_string, + ) + ) def realtime_situation_on_error(self, websocket, error: str) -> None: """Websocket callback when realtime situation socket error occurs @@ -300,11 +343,15 @@ def realtime_situation_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Realtime situation socket error: {0}".format(error)) - def realtime_situation_on_close(self, _websocket) -> None: + def realtime_situation_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the realtime situation connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.warning("Realtime situation socket close") diff --git a/wrappers/python/examples/wnt/authentication.py b/wrappers/python/examples/wnt/authentication.py index ccf7077..22fb88c 100644 --- a/wrappers/python/examples/wnt/authentication.py +++ b/wrappers/python/examples/wnt/authentication.py @@ -187,13 +187,17 @@ def authentication_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Socket error: {0}".format(error)) - def authentication_on_close(self, _websocket) -> None: + def authentication_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the authentication connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ - self.logger.info("Socket close") + self.logger.info("Authentication socket close") def run(self) -> int: """Run method which starts and waits the communication thread(s) diff --git a/wrappers/python/examples/wnt/building.py b/wrappers/python/examples/wnt/building.py index e818270..c2ab284 100644 --- a/wrappers/python/examples/wnt/building.py +++ b/wrappers/python/examples/wnt/building.py @@ -149,11 +149,15 @@ def authentication_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Authentication socket error: {0}".format(error)) - def authentication_on_close(self, _websocket) -> None: + def authentication_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the authentication connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.info("Authentication socket close") @@ -184,11 +188,15 @@ def metadata_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Metadata socket error: {0}".format(error)) - def metadata_on_close(self, _websocket) -> None: + def metadata_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the metadata connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.warning("Metadata socket close") diff --git a/wrappers/python/examples/wnt/componentsinformation.py b/wrappers/python/examples/wnt/componentsinformation.py index 3251156..079d843 100644 --- a/wrappers/python/examples/wnt/componentsinformation.py +++ b/wrappers/python/examples/wnt/componentsinformation.py @@ -154,11 +154,15 @@ def authentication_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Authentication socket error: {0}".format(error)) - def authentication_on_close(self, _websocket) -> None: + def authentication_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the authentication connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.info("Authentication socket close") @@ -189,11 +193,15 @@ def metadata_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Metadata socket error: {0}".format(error)) - def metadata_on_close(self, _websocket) -> None: + def metadata_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the metadata connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.warning("Metadata socket close") @@ -241,18 +249,21 @@ def realtime_situation_on_message(self, _websocket, message: str) -> None: self.send_request() else: - wnt_message = wnt_proto.Message() - wnt_message.ParseFromString(message) - - if wnt_message.HasField("gateway_info"): - self.logger.info("gateway_info:\n{}".format(wnt_message.gateway_info)) - - if wnt_message.HasField("backend_component_info"): - self.logger.info( - "backend_component_info:\n{}".format( - wnt_message.backend_component_info - ) - ) + wnt_message_collection = wnt_proto.MessageCollection() + wnt_message_collection.ParseFromString(message) + if wnt_message_collection.message_collection: + for wnt_message in wnt_message_collection.message_collection: + if wnt_message.HasField("gateway_info"): + self.logger.info( + "gateway_info:\n{}".format(wnt_message.gateway_info) + ) + + if wnt_message.HasField("backend_component_info"): + self.logger.info( + "backend_component_info:\n{}".format( + wnt_message.backend_component_info + ) + ) def realtime_situation_on_error(self, websocket, error: str) -> None: """Websocket callback when realtime situation socket error occurs @@ -264,11 +275,15 @@ def realtime_situation_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Realtime situation socket error: {0}".format(error)) - def realtime_situation_on_close(self, _websocket) -> None: + def realtime_situation_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the realtime situation connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.warning("Realtime situation socket close") diff --git a/wrappers/python/examples/wnt/connections.py b/wrappers/python/examples/wnt/connections.py old mode 100755 new mode 100644 index f2cc26b..703e6a1 --- a/wrappers/python/examples/wnt/connections.py +++ b/wrappers/python/examples/wnt/connections.py @@ -85,7 +85,7 @@ def __init__( self._realtime_situation_socket = self._create_realtime_situation_socket() # socket establishment - def _create_auth_socket(self, with_trace=True) -> websocket.WebSocketApp: + def _create_auth_socket(self, with_trace=False) -> websocket.WebSocketApp: websocket.enableTrace(with_trace) ws = websocket.WebSocketApp( self.endpoints["auth"], @@ -97,7 +97,7 @@ def _create_auth_socket(self, with_trace=True) -> websocket.WebSocketApp: return ws - def _create_meta_socket(self, with_trace=True) -> websocket.WebSocketApp: + def _create_meta_socket(self, with_trace=False) -> websocket.WebSocketApp: websocket.enableTrace(with_trace) ws = websocket.WebSocketApp( self.endpoints["meta"], @@ -110,7 +110,7 @@ def _create_meta_socket(self, with_trace=True) -> websocket.WebSocketApp: return ws def _create_realtime_situation_socket( - self, with_trace=True + self, with_trace=False ) -> websocket.WebSocketApp: websocket.enableTrace(with_trace) ws = websocket.WebSocketApp( diff --git a/wrappers/python/examples/wnt/floorplan.py b/wrappers/python/examples/wnt/floorplan.py index 9655e45..431ef25 100644 --- a/wrappers/python/examples/wnt/floorplan.py +++ b/wrappers/python/examples/wnt/floorplan.py @@ -290,11 +290,15 @@ def authentication_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Authentication socket error: {0}".format(error)) - def authentication_on_close(self, _websocket) -> None: + def authentication_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the authentication connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.info("Authentication socket close") @@ -325,11 +329,15 @@ def metadata_on_error(self, websocket, error) -> None: if websocket.keep_running: self.logger.error("Metadata socket error: {0}".format(error)) - def metadata_on_close(self, _websocket) -> None: + def metadata_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the metadata connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.warning("Metadata socket close") diff --git a/wrappers/python/examples/wnt/floorplanarea.py b/wrappers/python/examples/wnt/floorplanarea.py index 40fc0c5..c2e3bf3 100644 --- a/wrappers/python/examples/wnt/floorplanarea.py +++ b/wrappers/python/examples/wnt/floorplanarea.py @@ -347,11 +347,15 @@ def authentication_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Authentication socket error: {0}".format(error)) - def authentication_on_close(self, _websocket) -> None: + def authentication_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the authentication connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.info("Authentication socket close") @@ -382,11 +386,15 @@ def metadata_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Metadata socket error: {0}".format(error)) - def metadata_on_close(self, _websocket) -> None: + def metadata_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the metadata connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.warning("Metadata socket close") diff --git a/wrappers/python/examples/wnt/network.py b/wrappers/python/examples/wnt/network.py index 6367d6a..2f6cbc0 100644 --- a/wrappers/python/examples/wnt/network.py +++ b/wrappers/python/examples/wnt/network.py @@ -98,7 +98,9 @@ def send_request(self) -> None: elif self.state == self.State.DELETE_NETWORK: self.metadata_thread.socket.send( - json.dumps(self.messages.message_delete_network(self.new_network_id)) + json.dumps( + self.messages.message_delete_network(self.new_network_id, False) + ) ) def parse_response(self, message: str) -> bool: @@ -153,11 +155,15 @@ def authentication_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Authentication socket error: {0}".format(error)) - def authentication_on_close(self, _websocket) -> None: + def authentication_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the authentication connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.info("Authentication socket close") @@ -188,11 +194,15 @@ def metadata_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Metadata socket error: {0}".format(error)) - def metadata_on_close(self, _websocket) -> None: + def metadata_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the metadata connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.warning("Metadata socket close") diff --git a/wrappers/python/examples/wnt/node.py b/wrappers/python/examples/wnt/node.py index 211a615..b48b3b5 100644 --- a/wrappers/python/examples/wnt/node.py +++ b/wrappers/python/examples/wnt/node.py @@ -143,6 +143,7 @@ def send_request(self) -> None: 0.0, True, False, + True, ) ) ) @@ -247,9 +248,7 @@ def send_request(self) -> None: self.metadata_thread.socket.send( json.dumps( - self.messages.message_delete_node( - self.node_id, self.network_id, False - ) + self.messages.message_delete_node(self.node_id, self.network_id) ) ) @@ -352,11 +351,15 @@ def authentication_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Authentication socket error: {0}".format(error)) - def authentication_on_close(self, _websocket) -> None: + def authentication_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the authentication connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.info("Authentication socket close") @@ -387,11 +390,15 @@ def metadata_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Metadata socket error: {0}".format(error)) - def metadata_on_close(self, _websocket) -> None: + def metadata_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the metadata connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.warning("Metadata socket close") diff --git a/wrappers/python/examples/wnt/nodedatamessage.py b/wrappers/python/examples/wnt/nodedatamessage.py index f1ef5e9..32dbf18 100644 --- a/wrappers/python/examples/wnt/nodedatamessage.py +++ b/wrappers/python/examples/wnt/nodedatamessage.py @@ -131,11 +131,15 @@ def authentication_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Authentication socket error: {0}".format(error)) - def authentication_on_close(self, _websocket) -> None: + def authentication_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the authentication connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.info("Authentication socket close") @@ -166,11 +170,15 @@ def metadata_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Metadata socket error: {0}".format(error)) - def metadata_on_close(self, _websocket) -> None: + def metadata_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the metadata connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.warning("Metadata socket close") diff --git a/wrappers/python/examples/wnt/realtimedata.py b/wrappers/python/examples/wnt/realtimedata.py index 14417e7..74076a8 100644 --- a/wrappers/python/examples/wnt/realtimedata.py +++ b/wrappers/python/examples/wnt/realtimedata.py @@ -125,11 +125,15 @@ def authentication_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Authentication socket error: {0}".format(error)) - def authentication_on_close(self, _websocket) -> None: + def authentication_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the authentication connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.info("Authentication socket close") @@ -175,10 +179,14 @@ def realtime_situation_on_message(self, _websocket, message: str) -> None: # Initial nodes' data loaded self.state = self.State(self.state.value + 1) - wnt_message = wnt_proto.Message() - wnt_message.ParseFromString(message) - - self.logger.info(str(wnt_message)) + # Received message is either message collection or a single + # (heartbeat) message. In this case, only the message collections + # are of interest + wnt_message_collection = wnt_proto.MessageCollection() + wnt_message_collection.ParseFromString(message) + if wnt_message_collection.message_collection: + for wnt_message in wnt_message_collection.message_collection: + self.logger.info(str(wnt_message)) def realtime_situation_on_error(self, websocket, error: str) -> None: """Websocket callback when realtime situation socket error occurs @@ -190,11 +198,15 @@ def realtime_situation_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Realtime situation socket error: {0}".format(error)) - def realtime_situation_on_close(self, _websocket) -> None: + def realtime_situation_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the realtime situation connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.warning("Realtime situation socket close") diff --git a/wrappers/python/examples/wnt/requirements.txt b/wrappers/python/examples/wnt/requirements.txt new file mode 100644 index 0000000..fe93229 --- /dev/null +++ b/wrappers/python/examples/wnt/requirements.txt @@ -0,0 +1,3 @@ +# Minimal requirements for running the examples +websocket-client==1.0.1 +PyYAML==5.4.1 diff --git a/wrappers/python/examples/wnt/scratchpadstatus.py b/wrappers/python/examples/wnt/scratchpadstatus.py index a39209f..fb4f27a 100644 --- a/wrappers/python/examples/wnt/scratchpadstatus.py +++ b/wrappers/python/examples/wnt/scratchpadstatus.py @@ -46,7 +46,7 @@ class State(Enum): REALTIME_SITUATION_LOGIN = auto() WAIT_FOR_STARTUP_SITUATION = auto() - QUERY_SCRATCHPAD_STATUS = auto() + GET_SCRATCHPAD_STATUS = auto() WAIT_FOREVER = auto() END = auto() @@ -106,10 +106,10 @@ def send_request(self) -> None: ) ) - elif self.state == self.State.QUERY_SCRATCHPAD_STATUS: + elif self.state == self.State.GET_SCRATCHPAD_STATUS: self.metadata_thread.socket.send( json.dumps( - self.messages.message_query_scratchpad_status(777555, 0, False) + self.messages.message_get_scratchpad_status(777555, 0, False, False) ) ) @@ -125,8 +125,8 @@ def parse_response(self, message: str) -> bool: if self.state == self.State.LOGIN: return self.messages.parse_login(json.loads(message)) - elif self.state == self.state.QUERY_SCRATCHPAD_STATUS: - return self.messages.parse_query_scratchpad_status(json.loads(message)) + elif self.state == self.state.GET_SCRATCHPAD_STATUS: + return self.messages.parse_get_scratchpad_status(json.loads(message)) def authentication_on_open(self, _websocket) -> None: """Websocket callback when the authentication websocket has been opened @@ -156,11 +156,15 @@ def authentication_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Authentication socket error: {0}".format(error)) - def authentication_on_close(self, _websocket) -> None: + def authentication_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the authentication connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.info("Authentication socket close") @@ -191,11 +195,15 @@ def metadata_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Metadata socket error: {0}".format(error)) - def metadata_on_close(self, _websocket) -> None: + def metadata_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the metadata connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.warning("Metadata socket close") @@ -242,17 +250,18 @@ def realtime_situation_on_message(self, _websocket, message: str) -> None: self.state = self.State(self.state.value + 1) self.send_request() - wnt_message = wnt_proto.Message() - wnt_message.ParseFromString(message) - - if wnt_message.HasField("scratchpad_status"): - self.logger.info( - "scratchpad_status:\nnetwork id: {}\nnode id: {}\n{}".format( - wnt_message.network_id, - wnt_message.source_address, - wnt_message.scratchpad_status, - ) - ) + wnt_message_collection = wnt_proto.MessageCollection() + wnt_message_collection.ParseFromString(message) + if wnt_message_collection.message_collection: + for wnt_message in wnt_message_collection.message_collection: + if wnt_message.HasField("scratchpad_status"): + self.logger.info( + "scratchpad_status:\nnetwork id: {}\nnode id: {}\n{}".format( + wnt_message.network_id, + wnt_message.source_address, + wnt_message.scratchpad_status, + ) + ) def realtime_situation_on_error(self, websocket, error: str) -> None: """Websocket callback when realtime situation socket error occurs @@ -264,11 +273,15 @@ def realtime_situation_on_error(self, websocket, error: str) -> None: if websocket.keep_running: self.logger.error("Realtime situation socket error: {0}".format(error)) - def realtime_situation_on_close(self, _websocket) -> None: + def realtime_situation_on_close( + self, _websocket, close_status_code: int = None, reason: str = None + ) -> None: """Websocket callback when the realtime situation connection closes Args: _websocket (Websocket): communication socket + close_status_code (int): status code for close operation + reason (str): close reason """ self.logger.warning("Realtime situation socket close") diff --git a/wrappers/python/examples/wnt/utils.py b/wrappers/python/examples/wnt/utils.py old mode 100755 new mode 100644 index d36a2b2..f8680d8 --- a/wrappers/python/examples/wnt/utils.py +++ b/wrappers/python/examples/wnt/utils.py @@ -29,7 +29,7 @@ def __str__(self): def print_to_tty(message: dict) -> None: - """ send message to stdout""" + """send message to stdout""" print(str(message)) @@ -126,7 +126,7 @@ def parse_args(): ) parser.add_argument( - "--protocol_version", type=int, default=4, help="WS API protocol version." + "--protocol_version", type=int, default=5, help="WS API protocol version." ) parser.add_argument( diff --git a/wrappers/python/wirepas_messaging/wnt/ws_api/areamessages.py b/wrappers/python/wirepas_messaging/wnt/ws_api/areamessages.py index a091982..5e44da8 100644 --- a/wrappers/python/wirepas_messaging/wnt/ws_api/areamessages.py +++ b/wrappers/python/wirepas_messaging/wnt/ws_api/areamessages.py @@ -38,7 +38,6 @@ def message_get_floor_plan_areas(self, floor_plan_id: str) -> dict: type=AuthenticationMessages.MessageTypes.GET_MAP_AREAS.value, data=dict( buildings=[dict(floor_plans=[dict(id=floor_plan_id)])], - originator_token=self.originator_token, ), ) diff --git a/wrappers/python/wirepas_messaging/wnt/ws_api/buildingmessages.py b/wrappers/python/wirepas_messaging/wnt/ws_api/buildingmessages.py index d80e21e..c3129b3 100644 --- a/wrappers/python/wirepas_messaging/wnt/ws_api/buildingmessages.py +++ b/wrappers/python/wirepas_messaging/wnt/ws_api/buildingmessages.py @@ -121,7 +121,7 @@ def message_get_buildings(self) -> dict: version=self.protocol_version, session_id=self.session_id, type=AuthenticationMessages.MessageTypes.GET_BUILDINGS.value, - data=dict(originator_token=self.originator_token), + data=dict(), ) self.logger.info(self.json_dump_pretty(message)) diff --git a/wrappers/python/wirepas_messaging/wnt/ws_api/floorplanmessages.py b/wrappers/python/wirepas_messaging/wnt/ws_api/floorplanmessages.py index cd00ffb..b8e29dd 100644 --- a/wrappers/python/wirepas_messaging/wnt/ws_api/floorplanmessages.py +++ b/wrappers/python/wirepas_messaging/wnt/ws_api/floorplanmessages.py @@ -176,7 +176,7 @@ def message_get_floor_plans(self, building_id: str) -> dict: session_id=self.session_id, type=AuthenticationMessages.MessageTypes.GET_BUILDINGS_FLOOR_PLANS.value, data=dict( - buildings=[dict(id=building_id)], originator_token=self.originator_token + buildings=[dict(id=building_id)], ), ) @@ -253,7 +253,7 @@ def message_get_image(self, image_id: str) -> dict: version=self.protocol_version, session_id=self.session_id, type=AuthenticationMessages.MessageTypes.GET_FLOOR_PLAN_IMAGE_DATA.value, - data=dict(image_id=image_id, originator_token=self.originator_token), + data=dict(image_id=image_id), ) self.logger.info(self.json_dump_pretty(message)) diff --git a/wrappers/python/wirepas_messaging/wnt/ws_api/messagesbase.py b/wrappers/python/wirepas_messaging/wnt/ws_api/messagesbase.py index 6ac3126..eb55695 100644 --- a/wrappers/python/wirepas_messaging/wnt/ws_api/messagesbase.py +++ b/wrappers/python/wirepas_messaging/wnt/ws_api/messagesbase.py @@ -62,7 +62,9 @@ class MessageTypes(enum.Enum): SET_NETWORK_DATA = 1071 SEND_REMOTE_API_REQUEST = 1072 SEND_DATA_MESSAGE = 1073 - QUERY_SCRATCHPAD_STATUS = 1074 + GET_SCRATCHPAD_STATUS = 1074 + SET_OTAP_STATE = 1075 + SET_SCRATCHPAD_ACTION = 1076 QUERY_COMPONENTS_INFORMATION = 1081 diff --git a/wrappers/python/wirepas_messaging/wnt/ws_api/networkmessages.py b/wrappers/python/wirepas_messaging/wnt/ws_api/networkmessages.py index d924d0d..9b82c26 100644 --- a/wrappers/python/wirepas_messaging/wnt/ws_api/networkmessages.py +++ b/wrappers/python/wirepas_messaging/wnt/ws_api/networkmessages.py @@ -108,7 +108,7 @@ def message_get_networks(self) -> dict: version=self.protocol_version, session_id=self.session_id, type=AuthenticationMessages.MessageTypes.GET_NETWORKS.value, - data=dict(originator_token=self.originator_token), + data=dict(), ) self.logger.info(self.json_dump_pretty(message)) @@ -127,24 +127,26 @@ def parse_get_networks(self, message: dict) -> bool: self.validate(message) self.logger.info(self.json_dump_pretty(message)) except ValueError: - self.logger.error("Cannot delete network") + self.logger.error("Cannot get networks") self.logger.error(self.json_dump_pretty(message)) return False return True - def message_delete_network(self, network_id: str) -> dict: + def message_delete_network(self, network_id: str, is_delete_nodes: bool) -> dict: """Returns network delete message Args: network_id (str): network id + is_detete_nodes (bool): flag controlling whether to delete also nodes in the deleted network """ message = dict( version=self.protocol_version, session_id=self.session_id, type=AuthenticationMessages.MessageTypes.DELETE_NETWORK.value, data=dict( - networks=[dict(id=network_id)], originator_token=self.originator_token + networks=[dict(id=network_id, is_delete_nodes=is_delete_nodes)], + originator_token=self.originator_token, ), ) diff --git a/wrappers/python/wirepas_messaging/wnt/ws_api/nodemessages.py b/wrappers/python/wirepas_messaging/wnt/ws_api/nodemessages.py index d9f4274..ed74a8c 100644 --- a/wrappers/python/wirepas_messaging/wnt/ws_api/nodemessages.py +++ b/wrappers/python/wirepas_messaging/wnt/ws_api/nodemessages.py @@ -35,6 +35,7 @@ def message_set_node_metadata( altitude: float, is_approved: bool, is_virtual: bool, + is_anchor: bool, ) -> dict: """Returns set node metadata message @@ -48,6 +49,7 @@ def message_set_node_metadata( altitude (float): node's altitude is_approved (bool): is node approved is_virtual (bool): is node used for planning + is_anchor (bool): is node an anchor in positioning use case """ message = dict( version=self.protocol_version, @@ -65,6 +67,7 @@ def message_set_node_metadata( altitude=altitude, is_approved=is_approved, is_virtual=is_virtual, + is_anchor=is_anchor, ) ], originator_token=self.originator_token, @@ -183,20 +186,19 @@ def parse_remove_node_from_floor_plan(self, message: dict) -> bool: return True - def message_delete_node(self, node_id: int, network_id: int, is_sink: bool) -> dict: + def message_delete_node(self, node_id: int, network_id: int) -> dict: """Returns delete node message Args: node_id (int): node id network_id (int): node's network id - is_sink (bool): is node sink """ message = dict( version=self.protocol_version, session_id=self.session_id, type=AuthenticationMessages.MessageTypes.DELETE_NODE.value, data=dict( - nodes=[dict(id=node_id, network_id=network_id, is_sink=is_sink)], + nodes=[dict(id=node_id, network_id=network_id)], originator_token=self.originator_token, ), ) diff --git a/wrappers/python/wirepas_messaging/wnt/ws_api/scratchpadstatusmessages.py b/wrappers/python/wirepas_messaging/wnt/ws_api/scratchpadstatusmessages.py index b55183f..178f2ed 100644 --- a/wrappers/python/wirepas_messaging/wnt/ws_api/scratchpadstatusmessages.py +++ b/wrappers/python/wirepas_messaging/wnt/ws_api/scratchpadstatusmessages.py @@ -23,27 +23,33 @@ def __init__(self, logger, protocol_version): """ super(ScratchpadStatusMessages, self).__init__(logger, protocol_version) - def message_query_scratchpad_status( - self, network_id: int, rerun_interval_s: int, is_close: bool + def message_get_scratchpad_status( + self, + network_id: int, + resend_interval_s: int, + is_close: bool, + is_sink_only: bool, ) -> dict: - """Returns query scratchpad status message + """Returns get scratchpad status message Args: network_id (int): network id - rerun_interval_s (int): how often the query should be sent - is_close (bool): set to true to stop repeated querying + resend_interval_s (int): how often the get scratchpad should be run + is_close (bool): set to true to stop repeated gets + is_sink_only (bool): set to true to get scratchpad status only from sink nodes """ message = dict( version=self.protocol_version, session_id=self.session_id, - type=AuthenticationMessages.MessageTypes.QUERY_SCRATCHPAD_STATUS.value, + type=AuthenticationMessages.MessageTypes.GET_SCRATCHPAD_STATUS.value, data=dict( networks=[ dict( id=network_id, - rerun_interval_s=rerun_interval_s, + resend_interval_s=resend_interval_s, is_close=is_close, + is_sink_only=is_sink_only, ) ] ), @@ -52,11 +58,11 @@ def message_query_scratchpad_status( self.logger.info(self.json_dump_pretty(message)) return message - def parse_query_scratchpad_status(self, message: dict) -> bool: - """Parses query scratchpad status response + def parse_get_scratchpad_status(self, message: dict) -> bool: + """Parses get scratchpad status response Args: - message (dict): the query scratchpad status response + message (dict): the get scratchpad status response Returns: bool: True if message validation succeeded, else False