wiliot-certificate 4.4.3__py3-none-any.whl → 4.5.0a1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. {brg_certificate → certificate}/ag/wlt_cmd_if.html +10 -4
  2. {brg_certificate → certificate}/ag/wlt_types_ag.py +1878 -519
  3. {brg_certificate → certificate}/ag/wlt_types_ag_jsons/brg2brg_ota.json +69 -0
  4. {brg_certificate → certificate}/ag/wlt_types_ag_jsons/brg2gw_hb.json +109 -0
  5. {brg_certificate → certificate}/ag/wlt_types_ag_jsons/brg2gw_hb_sleep.json +45 -0
  6. {brg_certificate → certificate}/ag/wlt_types_ag_jsons/calibration.json +96 -0
  7. {brg_certificate → certificate}/ag/wlt_types_ag_jsons/custom.json +99 -0
  8. {brg_certificate → certificate}/ag/wlt_types_ag_jsons/datapath.json +241 -13
  9. {brg_certificate → certificate}/ag/wlt_types_ag_jsons/energy2400.json +120 -0
  10. {brg_certificate → certificate}/ag/wlt_types_ag_jsons/energySub1g.json +96 -0
  11. {brg_certificate → certificate}/ag/wlt_types_ag_jsons/externalSensor.json +135 -6
  12. {brg_certificate → certificate}/ag/wlt_types_ag_jsons/interface.json +157 -0
  13. {brg_certificate → certificate}/ag/wlt_types_ag_jsons/powerManagement.json +205 -0
  14. brg_certificate/ag/wlt_types_ag_jsons/unified_echo_pkt.json → certificate/ag/wlt_types_ag_jsons/unified_echo_ext_pkt.json +27 -11
  15. certificate/ag/wlt_types_ag_jsons/unified_echo_pkt.json +175 -0
  16. certificate/ag/wlt_types_ag_jsons/unified_sensor_pkt.json +65 -0
  17. certificate/cert_common.py +1459 -0
  18. certificate/cert_config.py +455 -0
  19. {brg_certificate → certificate}/cert_data_sim.py +131 -46
  20. {brg_certificate → certificate}/cert_defines.py +120 -128
  21. {brg_certificate → certificate}/cert_gw_sim.py +151 -49
  22. {brg_certificate → certificate}/cert_mqtt.py +164 -59
  23. {brg_certificate → certificate}/cert_prints.py +34 -33
  24. {brg_certificate → certificate}/cert_protobuf.py +15 -6
  25. {brg_certificate → certificate}/cert_results.py +205 -48
  26. certificate/cert_utils.py +622 -0
  27. certificate/certificate.py +198 -0
  28. certificate/certificate_cli.py +79 -0
  29. certificate/certificate_eth_test_list.txt +74 -0
  30. certificate/certificate_sanity_test_list.txt +65 -0
  31. certificate/certificate_test_list.txt +75 -0
  32. {brg_certificate → certificate}/tests/calibration/interval_test/interval_test.json +2 -2
  33. {brg_certificate → certificate}/tests/calibration/interval_test/interval_test.py +7 -6
  34. certificate/tests/calibration/output_power_test/output_power_test.json +22 -0
  35. certificate/tests/calibration/output_power_test/output_power_test.py +39 -0
  36. {brg_certificate → certificate}/tests/calibration/pattern_test/pattern_test.json +1 -1
  37. {brg_certificate → certificate}/tests/calibration/pattern_test/pattern_test.py +20 -15
  38. certificate/tests/cloud_connectivity/acl_ext_adv_test/acl_ext_adv_test.json +14 -0
  39. certificate/tests/cloud_connectivity/acl_ext_adv_test/acl_ext_adv_test.py +140 -0
  40. certificate/tests/cloud_connectivity/acl_test/acl_test.json +14 -0
  41. certificate/tests/cloud_connectivity/acl_test/acl_test.py +98 -0
  42. certificate/tests/cloud_connectivity/brg_ota_test/brg_ota_test.json +18 -0
  43. certificate/tests/cloud_connectivity/brg_ota_test/brg_ota_test.py +39 -0
  44. certificate/tests/cloud_connectivity/channel_scan_behaviour_test/channel_scan_behaviour_test.json +18 -0
  45. certificate/tests/cloud_connectivity/channel_scan_behaviour_test/channel_scan_behaviour_test.py +215 -0
  46. certificate/tests/cloud_connectivity/connection_test/connection_test.json +17 -0
  47. certificate/tests/cloud_connectivity/connection_test/connection_test.py +74 -0
  48. certificate/tests/cloud_connectivity/downlink_test/downlink_test.json +20 -0
  49. certificate/tests/cloud_connectivity/downlink_test/downlink_test.py +204 -0
  50. certificate/tests/cloud_connectivity/ext_adv_stress_test/ext_adv_stress_test.json +16 -0
  51. certificate/tests/cloud_connectivity/ext_adv_stress_test/ext_adv_stress_test.py +98 -0
  52. certificate/tests/cloud_connectivity/reboot_test/reboot_test.json +17 -0
  53. certificate/tests/cloud_connectivity/reboot_test/reboot_test.py +57 -0
  54. certificate/tests/cloud_connectivity/registration_test/registration_test.json +19 -0
  55. certificate/tests/cloud_connectivity/registration_test/registration_test.py +384 -0
  56. certificate/tests/cloud_connectivity/registration_test/registration_test_cli.py +90 -0
  57. certificate/tests/cloud_connectivity/stress_test/stress_test.json +16 -0
  58. certificate/tests/cloud_connectivity/stress_test/stress_test.py +97 -0
  59. certificate/tests/cloud_connectivity/uplink_ext_adv_test/uplink_ext_adv_test.json +24 -0
  60. certificate/tests/cloud_connectivity/uplink_ext_adv_test/uplink_ext_adv_test.py +93 -0
  61. certificate/tests/cloud_connectivity/uplink_test/uplink_test.json +19 -0
  62. certificate/tests/cloud_connectivity/uplink_test/uplink_test.py +161 -0
  63. {brg_certificate → certificate}/tests/datapath/aging_test/aging_test.json +1 -1
  64. certificate/tests/datapath/aging_test/aging_test.py +138 -0
  65. certificate/tests/datapath/event_ble5_test/event_ble5_test.json +16 -0
  66. certificate/tests/datapath/event_ble5_test/event_ble5_test.py +95 -0
  67. certificate/tests/datapath/event_test/event_test.json +16 -0
  68. certificate/tests/datapath/event_test/event_test.py +85 -0
  69. {brg_certificate → certificate}/tests/datapath/num_of_tags_test/num_of_tags_test.json +1 -1
  70. {brg_certificate → certificate}/tests/datapath/num_of_tags_test/num_of_tags_test.py +10 -8
  71. certificate/tests/datapath/output_power_test/output_power_test.json +22 -0
  72. {brg_certificate → certificate}/tests/datapath/output_power_test/output_power_test.py +17 -6
  73. {brg_certificate → certificate}/tests/datapath/pacer_interval_ble5_test/pacer_interval_ble5_test.json +1 -1
  74. {brg_certificate → certificate}/tests/datapath/pacer_interval_ble5_test/pacer_interval_ble5_test.py +10 -8
  75. {brg_certificate → certificate}/tests/datapath/pacer_interval_test/pacer_interval_test.json +1 -1
  76. {brg_certificate → certificate}/tests/datapath/pacer_interval_test/pacer_interval_test.py +9 -7
  77. {brg_certificate → certificate}/tests/datapath/pattern_test/pattern_test.json +2 -2
  78. {brg_certificate → certificate}/tests/datapath/pattern_test/pattern_test.py +18 -6
  79. certificate/tests/datapath/pkt_filter_ble5_chl21_test/pkt_filter_ble5_chl21_test.json +19 -0
  80. certificate/tests/datapath/pkt_filter_ble5_chl21_test/pkt_filter_ble5_chl21_test.py +61 -0
  81. {brg_certificate → certificate}/tests/datapath/pkt_filter_ble5_test/pkt_filter_ble5_test.json +1 -1
  82. {brg_certificate → certificate}/tests/datapath/pkt_filter_ble5_test/pkt_filter_ble5_test.py +11 -10
  83. certificate/tests/datapath/pkt_filter_brg2gw_ext_adv_test/pkt_filter_brg2gw_ext_adv_test.json +18 -0
  84. certificate/tests/datapath/pkt_filter_brg2gw_ext_adv_test/pkt_filter_brg2gw_ext_adv_test.py +83 -0
  85. {brg_certificate → certificate}/tests/datapath/pkt_filter_gen3_test/pkt_filter_gen3_test.json +1 -1
  86. {brg_certificate → certificate}/tests/datapath/pkt_filter_gen3_test/pkt_filter_gen3_test.py +10 -9
  87. {brg_certificate → certificate}/tests/datapath/pkt_filter_test/pkt_filter_test.json +1 -1
  88. {brg_certificate → certificate}/tests/datapath/pkt_filter_test/pkt_filter_test.py +10 -9
  89. {brg_certificate → certificate}/tests/datapath/rssi_threshold_test/rssi_threshold_test.json +1 -1
  90. {brg_certificate → certificate}/tests/datapath/rssi_threshold_test/rssi_threshold_test.py +9 -8
  91. brg_certificate/tests/datapath/output_power_test/output_power_test.json → certificate/tests/datapath/rx_channel_hopping_test/rx_channel_hopping_test.json +5 -4
  92. certificate/tests/datapath/rx_channel_hopping_test/rx_channel_hopping_test.py +77 -0
  93. {brg_certificate → certificate}/tests/datapath/rx_channel_test/rx_channel_test.json +2 -2
  94. {brg_certificate → certificate}/tests/datapath/rx_channel_test/rx_channel_test.py +7 -6
  95. {brg_certificate → certificate}/tests/datapath/rx_rate_gen2_test/rx_rate_gen2_test.json +7 -7
  96. {brg_certificate → certificate}/tests/datapath/rx_rate_gen2_test/rx_rate_gen2_test.py +112 -72
  97. {brg_certificate → certificate}/tests/datapath/rx_rate_gen3_test/rx_rate_gen3_test.json +7 -7
  98. {brg_certificate → certificate}/tests/datapath/rx_rate_gen3_test/rx_rate_gen3_test.py +112 -72
  99. {brg_certificate → certificate}/tests/datapath/stress_gen3_test/stress_gen3_test.json +3 -3
  100. {brg_certificate → certificate}/tests/datapath/stress_gen3_test/stress_gen3_test.py +12 -11
  101. {brg_certificate → certificate}/tests/datapath/stress_test/stress_test.json +3 -3
  102. {brg_certificate → certificate}/tests/datapath/stress_test/stress_test.py +12 -11
  103. {brg_certificate → certificate}/tests/datapath/tx_repetition_test/tx_repetition_test.json +2 -1
  104. {brg_certificate → certificate}/tests/datapath/tx_repetition_test/tx_repetition_test.py +14 -13
  105. certificate/tests/edge_mgmt/action_blink_test/action_blink_test.json +14 -0
  106. certificate/tests/edge_mgmt/action_blink_test/action_blink_test.py +24 -0
  107. certificate/tests/edge_mgmt/action_get_battery_sensor_test/action_get_battery_sensor_test.json +14 -0
  108. certificate/tests/edge_mgmt/action_get_battery_sensor_test/action_get_battery_sensor_test.py +43 -0
  109. certificate/tests/edge_mgmt/action_get_module_test/action_get_module_test.json +14 -0
  110. certificate/tests/edge_mgmt/action_get_module_test/action_get_module_test.py +42 -0
  111. certificate/tests/edge_mgmt/action_get_pof_data_test/action_get_pof_data_test.json +14 -0
  112. certificate/tests/edge_mgmt/action_get_pof_data_test/action_get_pof_data_test.py +44 -0
  113. certificate/tests/edge_mgmt/action_gw_hb_test/action_gw_hb_test.json +15 -0
  114. certificate/tests/edge_mgmt/action_gw_hb_test/action_gw_hb_test.py +42 -0
  115. certificate/tests/edge_mgmt/action_reboot_test/action_reboot_test.json +14 -0
  116. certificate/tests/edge_mgmt/action_reboot_test/action_reboot_test.py +49 -0
  117. certificate/tests/edge_mgmt/action_restore_defaults_test/action_restore_defaults_test.json +14 -0
  118. certificate/tests/edge_mgmt/action_restore_defaults_test/action_restore_defaults_test.py +102 -0
  119. certificate/tests/edge_mgmt/action_send_hb_test/action_send_hb_test.json +14 -0
  120. certificate/tests/edge_mgmt/action_send_hb_test/action_send_hb_test.py +41 -0
  121. {brg_certificate → certificate}/tests/edge_mgmt/periodic_msgs_test/periodic_msgs_test.json +2 -2
  122. {brg_certificate → certificate}/tests/edge_mgmt/periodic_msgs_test/periodic_msgs_test.py +22 -11
  123. {brg_certificate → certificate}/tests/energy2400/duty_cycle_test/duty_cycle_test.json +1 -1
  124. {brg_certificate → certificate}/tests/energy2400/duty_cycle_test/duty_cycle_test.py +7 -6
  125. certificate/tests/energy2400/output_power_test/output_power_test.json +22 -0
  126. {brg_certificate → certificate}/tests/energy2400/output_power_test/output_power_test.py +17 -6
  127. {brg_certificate → certificate}/tests/energy2400/pattern_test/pattern_test.json +1 -1
  128. {brg_certificate → certificate}/tests/energy2400/pattern_test/pattern_test.py +7 -6
  129. certificate/tests/energy2400/signal_indicator_ble5_test/signal_indicator_ble5_test.json +25 -0
  130. certificate/tests/energy2400/signal_indicator_ble5_test/signal_indicator_ble5_test.py +378 -0
  131. brg_certificate/tests/energy2400/signal_indicator_ble5_10_500k_test/signal_indicator_ble5_10_500k_test.json → certificate/tests/energy2400/signal_indicator_ext_adv_test/signal_indicator_ext_adv_test.json +3 -3
  132. brg_certificate/tests/energy2400/signal_indicator_ble5_10_500k_test/signal_indicator_ble5_10_500k_test.py → certificate/tests/energy2400/signal_indicator_ext_adv_test/signal_indicator_ext_adv_test.py +97 -87
  133. certificate/tests/energy2400/signal_indicator_test/signal_indicator_test.json +23 -0
  134. certificate/tests/energy2400/signal_indicator_test/signal_indicator_test.py +350 -0
  135. {brg_certificate → certificate}/tests/energy_sub1g/duty_cycle_test/duty_cycle_test.json +1 -1
  136. {brg_certificate → certificate}/tests/energy_sub1g/duty_cycle_test/duty_cycle_test.py +7 -6
  137. {brg_certificate → certificate}/tests/energy_sub1g/pattern_test/pattern_test.json +1 -1
  138. {brg_certificate → certificate}/tests/energy_sub1g/pattern_test/pattern_test.py +7 -6
  139. {brg_certificate → certificate}/tests/pwr_mgmt/pwr_mgmt_test/pwr_mgmt_test.json +1 -1
  140. {brg_certificate → certificate}/tests/pwr_mgmt/pwr_mgmt_test/pwr_mgmt_test.py +10 -10
  141. {brg_certificate → certificate}/tests/sensors/ext_sensor_test/ext_sensor_test.json +4 -4
  142. certificate/tests/sensors/ext_sensor_test/ext_sensor_test.py +455 -0
  143. certificate/wlt_types.py +122 -0
  144. {gw_certificate → common}/api_if/202/status.json +6 -0
  145. {gw_certificate → common}/api_if/203/status.json +6 -0
  146. {gw_certificate → common}/api_if/204/status.json +6 -0
  147. common/api_if/206/data.json +85 -0
  148. common/api_if/206/status.json +69 -0
  149. common/api_if/api_validation.py +85 -0
  150. common/web/templates/generator.html +148 -0
  151. common/web/templates/index.html +20 -0
  152. common/web/templates/menu.html +54 -0
  153. common/web/templates/parser.html +53 -0
  154. {brg_certificate/ag → common/web/templates}/wlt_types.html +1216 -191
  155. common/web/web_utils.py +377 -0
  156. {brg_certificate → common}/wltPb_pb2.py +14 -12
  157. {gw_certificate/common → common}/wltPb_pb2.pyi +16 -2
  158. gui_certificate/gui_certificate_cli.py +14 -0
  159. gui_certificate/server.py +1062 -0
  160. gui_certificate/templates/cert_run.html +1207 -0
  161. wiliot_certificate-4.5.0a1.dist-info/METADATA +110 -0
  162. wiliot_certificate-4.5.0a1.dist-info/RECORD +182 -0
  163. {wiliot_certificate-4.4.3.dist-info → wiliot_certificate-4.5.0a1.dist-info}/WHEEL +1 -1
  164. wiliot_certificate-4.5.0a1.dist-info/entry_points.txt +5 -0
  165. wiliot_certificate-4.5.0a1.dist-info/top_level.txt +3 -0
  166. brg_certificate/ag/energous_v0_defines.py +0 -925
  167. brg_certificate/ag/energous_v1_defines.py +0 -931
  168. brg_certificate/ag/energous_v2_defines.py +0 -925
  169. brg_certificate/ag/energous_v3_defines.py +0 -925
  170. brg_certificate/ag/energous_v4_defines.py +0 -925
  171. brg_certificate/ag/fanstel_lan_v0_defines.py +0 -925
  172. brg_certificate/ag/fanstel_lte_v0_defines.py +0 -925
  173. brg_certificate/ag/fanstel_wifi_v0_defines.py +0 -925
  174. brg_certificate/ag/minew_lte_v0_defines.py +0 -925
  175. brg_certificate/ag/wlt_types_ag_jsons/unified_echo_ext_pkt.json +0 -61
  176. brg_certificate/brg_certificate.py +0 -225
  177. brg_certificate/brg_certificate_cli.py +0 -63
  178. brg_certificate/cert_common.py +0 -923
  179. brg_certificate/cert_config.py +0 -402
  180. brg_certificate/cert_utils.py +0 -362
  181. brg_certificate/certificate_bcc_sanity_test_list.txt +0 -40
  182. brg_certificate/certificate_bcc_test_list.txt +0 -48
  183. brg_certificate/certificate_sanity_test_list.txt +0 -43
  184. brg_certificate/certificate_test_list.txt +0 -53
  185. brg_certificate/config/eclipse.json +0 -10
  186. brg_certificate/config/hivemq.json +0 -10
  187. brg_certificate/config/mosquitto.json +0 -10
  188. brg_certificate/config/mosquitto.md +0 -95
  189. brg_certificate/config/wiliot-dev.json +0 -10
  190. brg_certificate/restore_brg.py +0 -61
  191. brg_certificate/tests/calibration/output_power_test/output_power_test.json +0 -16
  192. brg_certificate/tests/calibration/output_power_test/output_power_test.py +0 -28
  193. brg_certificate/tests/datapath/aging_test/aging_test.py +0 -143
  194. brg_certificate/tests/datapath/pacer_interval_tags_count_test/pacer_interval_tags_count_test.json +0 -16
  195. brg_certificate/tests/datapath/pacer_interval_tags_count_test/pacer_interval_tags_count_test.py +0 -73
  196. brg_certificate/tests/datapath/tx_repetition_algo_test/tx_repetition_algo_test.json +0 -17
  197. brg_certificate/tests/datapath/tx_repetition_algo_test/tx_repetition_algo_test.py +0 -118
  198. brg_certificate/tests/edge_mgmt/actions_test/actions_test.json +0 -14
  199. brg_certificate/tests/edge_mgmt/actions_test/actions_test.py +0 -396
  200. brg_certificate/tests/edge_mgmt/brg2brg_ota_ble5_test/brg2brg_ota_ble5_test.json +0 -20
  201. brg_certificate/tests/edge_mgmt/brg2brg_ota_ble5_test/brg2brg_ota_ble5_test.py +0 -94
  202. brg_certificate/tests/edge_mgmt/brg2brg_ota_test/brg2brg_ota_test.json +0 -19
  203. brg_certificate/tests/edge_mgmt/brg2brg_ota_test/brg2brg_ota_test.py +0 -87
  204. brg_certificate/tests/edge_mgmt/leds_test/leds_test.json +0 -17
  205. brg_certificate/tests/edge_mgmt/leds_test/leds_test.py +0 -223
  206. brg_certificate/tests/edge_mgmt/ota_test/ota_test.json +0 -17
  207. brg_certificate/tests/edge_mgmt/ota_test/ota_test.py +0 -128
  208. brg_certificate/tests/energy2400/output_power_test/output_power_test.json +0 -16
  209. brg_certificate/tests/energy2400/signal_indicator_ble5_10_250k_test/signal_indicator_ble5_10_250k_test.json +0 -20
  210. brg_certificate/tests/energy2400/signal_indicator_ble5_10_250k_test/signal_indicator_ble5_10_250k_test.py +0 -321
  211. brg_certificate/tests/energy2400/signal_indicator_sub1g_2_4_test/signal_indicator_sub1g_2_4_test.json +0 -20
  212. brg_certificate/tests/energy2400/signal_indicator_sub1g_2_4_test/signal_indicator_sub1g_2_4_test.py +0 -141
  213. brg_certificate/tests/energy2400/signal_indicator_test/signal_indicator_test.json +0 -20
  214. brg_certificate/tests/energy2400/signal_indicator_test/signal_indicator_test.py +0 -276
  215. brg_certificate/tests/energy_sub1g/signal_indicator_functionality_test/signal_indicator_functionality_test.json +0 -20
  216. brg_certificate/tests/energy_sub1g/signal_indicator_functionality_test/signal_indicator_functionality_test.py +0 -390
  217. brg_certificate/tests/energy_sub1g/signal_indicator_test/signal_indicator_test.json +0 -16
  218. brg_certificate/tests/energy_sub1g/signal_indicator_test/signal_indicator_test.py +0 -28
  219. brg_certificate/tests/sensors/ext_sensor_test/ext_sensor_test.py +0 -305
  220. brg_certificate/wltPb_pb2.pyi +0 -234
  221. brg_certificate/wlt_types.py +0 -113
  222. gw_certificate/ag/ut_defines.py +0 -364
  223. gw_certificate/ag/wlt_types.py +0 -85
  224. gw_certificate/ag/wlt_types_ag.py +0 -5310
  225. gw_certificate/ag/wlt_types_data.py +0 -64
  226. gw_certificate/api/extended_api.py +0 -23
  227. gw_certificate/api_if/200/data.json +0 -106
  228. gw_certificate/api_if/200/status.json +0 -47
  229. gw_certificate/api_if/201/data.json +0 -98
  230. gw_certificate/api_if/201/status.json +0 -53
  231. gw_certificate/api_if/205/logs.json +0 -12
  232. gw_certificate/api_if/api_validation.py +0 -38
  233. gw_certificate/api_if/gw_capabilities.py +0 -54
  234. gw_certificate/cert_results.py +0 -145
  235. gw_certificate/common/analysis_data_bricks.py +0 -60
  236. gw_certificate/common/debug.py +0 -42
  237. gw_certificate/common/serialization_formatter.py +0 -93
  238. gw_certificate/common/utils.py +0 -8
  239. gw_certificate/common/utils_defines.py +0 -15
  240. gw_certificate/common/wltPb_pb2.py +0 -84
  241. gw_certificate/gw_certificate.py +0 -154
  242. gw_certificate/gw_certificate_cli.py +0 -87
  243. gw_certificate/interface/4.4.93_app.zip +0 -0
  244. gw_certificate/interface/4.4.93_sd_bl_app.zip +0 -0
  245. gw_certificate/interface/ble_simulator.py +0 -61
  246. gw_certificate/interface/ble_sniffer.py +0 -189
  247. gw_certificate/interface/flash_fw.py +0 -90
  248. gw_certificate/interface/if_defines.py +0 -36
  249. gw_certificate/interface/mqtt.py +0 -563
  250. gw_certificate/interface/nrfutil-linux +0 -0
  251. gw_certificate/interface/nrfutil-mac +0 -0
  252. gw_certificate/interface/nrfutil.exe +0 -0
  253. gw_certificate/interface/pkt_generator.py +0 -594
  254. gw_certificate/interface/uart_if.py +0 -236
  255. gw_certificate/interface/uart_ports.py +0 -20
  256. gw_certificate/templates/results.html +0 -241
  257. gw_certificate/templates/stage.html +0 -22
  258. gw_certificate/templates/table.html +0 -6
  259. gw_certificate/templates/test.html +0 -38
  260. gw_certificate/tests/__init__.py +0 -10
  261. gw_certificate/tests/actions.py +0 -289
  262. gw_certificate/tests/bad_crc_to_PER_quantization.csv +0 -51
  263. gw_certificate/tests/connection.py +0 -188
  264. gw_certificate/tests/downlink.py +0 -172
  265. gw_certificate/tests/generic.py +0 -238
  266. gw_certificate/tests/registration.py +0 -340
  267. gw_certificate/tests/static/__init__.py +0 -0
  268. gw_certificate/tests/static/connection_defines.py +0 -9
  269. gw_certificate/tests/static/downlink_defines.py +0 -9
  270. gw_certificate/tests/static/generated_packet_table.py +0 -195
  271. gw_certificate/tests/static/packet_table.csv +0 -10067
  272. gw_certificate/tests/static/references.py +0 -5
  273. gw_certificate/tests/static/uplink_defines.py +0 -14
  274. gw_certificate/tests/throughput.py +0 -240
  275. gw_certificate/tests/uplink.py +0 -853
  276. wiliot_certificate-4.4.3.dist-info/METADATA +0 -211
  277. wiliot_certificate-4.4.3.dist-info/RECORD +0 -210
  278. wiliot_certificate-4.4.3.dist-info/entry_points.txt +0 -3
  279. wiliot_certificate-4.4.3.dist-info/top_level.txt +0 -3
  280. {brg_certificate → certificate}/__init__.py +0 -0
  281. {brg_certificate → certificate}/ag/wlt_types_ag_jsons/side_info_sensor.json +0 -0
  282. {brg_certificate → certificate}/ag/wlt_types_ag_jsons/signal_indicator_data.json +0 -0
  283. {gw_certificate → common}/api_if/202/data.json +0 -0
  284. {gw_certificate/api_if/200 → common/api_if/202}/logs.json +0 -0
  285. {gw_certificate → common}/api_if/203/data.json +0 -0
  286. {gw_certificate/api_if/201 → common/api_if/203}/logs.json +0 -0
  287. {gw_certificate → common}/api_if/204/data.json +0 -0
  288. {gw_certificate/api_if/202 → common/api_if/204}/logs.json +0 -0
  289. {gw_certificate → common}/api_if/205/data.json +0 -0
  290. {gw_certificate/api_if/203 → common/api_if/205}/logs.json +0 -0
  291. {gw_certificate → common}/api_if/205/status.json +0 -0
  292. {gw_certificate/api_if/204 → common/api_if/206}/logs.json +0 -0
  293. {gw_certificate → common/api_if}/__init__.py +0 -0
  294. {gw_certificate/api_if → gui_certificate}/__init__.py +0 -0
  295. {wiliot_certificate-4.4.3.dist-info → wiliot_certificate-4.5.0a1.dist-info}/licenses/LICENSE +0 -0
@@ -4,21 +4,36 @@ import re
4
4
  import paho.mqtt.client as mqtt
5
5
  import serial
6
6
  import serial.tools.list_ports
7
- from brg_certificate.cert_mqtt import *
8
- from brg_certificate.cert_defines import *
9
- from brg_certificate.cert_prints import *
10
- import brg_certificate.cert_common as cert_common
11
- from brg_certificate.cert_data_sim import PIXEL_SIM_INDICATOR, write_to_data_sim_log_file
12
- import brg_certificate.cert_utils as cert_utils
7
+ from certificate.cert_mqtt import *
8
+ from certificate.cert_defines import *
9
+ from certificate.cert_prints import *
10
+ import certificate.cert_common as cert_common
11
+ from certificate.cert_data_sim import PIXEL_SIM_INDICATOR, write_to_data_sim_log_file
12
+ import certificate.cert_utils as cert_utils
13
13
 
14
14
  # Generic Defines
15
- SERIAL_TIMEOUT = 0.1 # TODO decide about the right value
15
+ SERIAL_TIMEOUT = 0.05 # TODO decide about the right value
16
16
  STOP_ADVERTISING = '!stop_advertising'
17
17
  RESET_GW = '!reset'
18
18
  DEDUPLICATION_PKTS = '!deduplication_pkts'
19
+ GW_CERT_TESTER = '!gw_cert_tester'
19
20
  SET_RX_CHANNEL = '!set_rx_channel'
20
21
  VERSION = '!version'
21
22
  CONNECTIVITY_STATUS = '!connectivity_status'
23
+ BLE_SIM_INIT = '!ble_sim_init'
24
+ BLE_SIM = '!ble_sim'
25
+ BLE_SIM_EXT_ADV = '!ble_sim_ext_adv'
26
+
27
+ # Received RX uarts
28
+ RX_NORDIC_RECOVER_RESET = "NORDIC_RECOVER 1"
29
+ RX_NORDIC_RECOVER_NORESET = "NORDIC_RECOVER 0"
30
+ RX_RESET = "reset"
31
+
32
+ GW_SIM_RESET_TS = None
33
+
34
+ # Slip related
35
+ SLIP_END = 0xC0
36
+ UART_PKT_PREFIX_BYTE = 0x70
22
37
 
23
38
  # Interference Analysis Defines
24
39
  DEFAULT_LOOKOUT_TIME = 2
@@ -34,6 +49,7 @@ CNTRS_KEYS = [NON_WLT_RX, WLT_RX, BAD_CRC
34
49
 
35
50
  GW_STATUS_MESSAGES = []
36
51
 
52
+
37
53
  ##############################################
38
54
  # UART PKT TYPES
39
55
  ##############################################
@@ -41,9 +57,9 @@ class UplinkPkt(): # p6
41
57
  def __init__(self, gw, seq_id, raw):
42
58
  self.gw = gw
43
59
  self.seq_id = seq_id
44
- self.alias_brg_id = raw[0:12]
45
- self.payload = raw[12:74]
46
- self.rssi = int(raw[74:76], 16)
60
+ self.alias_brg_id = raw[2:14]
61
+ self.payload = raw[14:76]
62
+ self.rssi = int(raw[0:2], 16)
47
63
  def dump(self):
48
64
  return {
49
65
  GW_ID: self.gw, TIMESTAMP: time.time()*1000,
@@ -58,9 +74,26 @@ class UplinkExtendedPkt(): # p7
58
74
  def __init__(self, gw, seq_id, raw):
59
75
  self.gw = gw
60
76
  self.seq_id = seq_id
61
- self.alias_brg_id = raw[0:12]
62
- self.payload = raw[12:96] # 39 payload + 3 side info
63
- self.rssi = int(raw[96:98], 16)
77
+ self.alias_brg_id = raw[2:14]
78
+ self.payload = raw[14:98] # 39 payload + 3 side info
79
+ self.rssi = int(raw[0:2], 16)
80
+ def dump(self):
81
+ return {
82
+ GW_ID: self.gw, TIMESTAMP: time.time()*1000,
83
+ "packets": [{ALIAS_BRIDGE_ID: self.alias_brg_id,
84
+ TIMESTAMP: time.time()*1000,
85
+ SEQUENCE_ID: self.seq_id,
86
+ RSSI: self.rssi,
87
+ PAYLOAD: self.payload}]
88
+ }
89
+
90
+ class UplinkAggregatedPkt(): # p8
91
+ def __init__(self, gw, seq_id, raw):
92
+ self.gw = gw
93
+ self.seq_id = seq_id
94
+ self.alias_brg_id = raw[2:14]
95
+ self.payload = raw[14:]
96
+ self.rssi = int(raw[0:2], 16)
64
97
  def dump(self):
65
98
  return {
66
99
  GW_ID: self.gw, TIMESTAMP: time.time()*1000,
@@ -74,20 +107,30 @@ class UplinkExtendedPkt(): # p7
74
107
  ##############################################
75
108
  # UT HELPER FUNCTIONS
76
109
  ##############################################
77
- def prep_gw(args, mqttc, start_time):
78
- # Check GW is online and configure to defaults
79
- utPrint(SEP)
80
- utPrint("Checking UART response and configure internal brg to defaults", "BLUE")
81
- gw = args.gw
82
- protobuf = False
83
- internal_brg_mac_addr = os.getenv(GW_SIM_BLE_MAC_ADDRESS)
84
- internal_brg_ble_ver = os.getenv(GW_APP_VERSION_HEADER)
85
- if not internal_brg_mac_addr:
86
- cert_utils.handle_error(f"ERROR: Didn't receive {GW_SIM_BLE_MAC_ADDRESS} response!", start_time)
87
- internal_brg = cert_utils.ut_prep_brg(args, mqttc, start_time, gw, internal_brg_mac_addr, "prod", protobuf)
88
- if internal_brg.api_version != ag.API_VERSION_LATEST:
89
- cert_utils.handle_error(f"ERROR: Certificate FW api_version={internal_brg.api_version} instead of api_version={ag.API_VERSION_LATEST}! Please upgrade the FW!", start_time)
90
- return gw, internal_brg, "prod", {BLE_VERSION:internal_brg_ble_ver, WIFI_VERSION:"0.0.0"}, protobuf
110
+
111
+ def slip_decode(data: bytes) -> bytes:
112
+ SLIP_ESC = 0xDB
113
+ SLIP_ESC_END = 0xDC
114
+ SLIP_ESC_ESC = 0xDD
115
+
116
+ decoded = bytearray()
117
+ i = 0
118
+ while i < len(data):
119
+ byte = data[i]
120
+ if byte == SLIP_END:
121
+ i += 1
122
+ continue
123
+ elif byte == SLIP_ESC:
124
+ i += 1
125
+ if i < len(data):
126
+ if data[i] == SLIP_ESC_END:
127
+ decoded.append(SLIP_END)
128
+ elif data[i] == SLIP_ESC_ESC:
129
+ decoded.append(SLIP_ESC)
130
+ else:
131
+ decoded.append(byte)
132
+ i += 1
133
+ return bytes(decoded)
91
134
 
92
135
  ##############################################
93
136
  # UART FUNCTIONS
@@ -97,11 +140,55 @@ def write_to_ble(ble_serial, txt, print_enable=True, sleep=0):
97
140
  # print('\n' + txt)
98
141
  ble_serial.write(bytes(txt, encoding='utf-8') + b'\r\n')
99
142
  if sleep:
100
- cert_common.wait_time_n_print(sleep)
143
+ wait_time_n_print(sleep)
144
+
145
+ def read_frame(ble_serial: serial.Serial, frame_max_read_attempts: int = 5):
146
+ """
147
+ Read either [0xC0][data][0xC0] uart messages, or [data] message (for !version reply)
148
+
149
+ :return str/None: ascii string if read successfully. None otherwise
150
+ """
151
+ opening_delim_received = False
152
+ closing_delim_received = False
153
+ read_attempts = 0
154
+
155
+ input = ble_serial.read_until(expected=bytes([SLIP_END]))
156
+ # We got the opening SLIP_END delimiter, read the message.
157
+ # It's in a while loop to skip empty frames.
158
+ while len(input) == 1 and input[0] == SLIP_END:
159
+ opening_delim_received = True
160
+ if read_attempts > frame_max_read_attempts:
161
+ return None
162
+ input = ble_serial.read_until(expected=bytes([SLIP_END]))
163
+ read_attempts += 1
164
+
165
+ while opening_delim_received and not closing_delim_received:
166
+ # Keep reading until we get the closing delimiter
167
+ if input[-1] == SLIP_END:
168
+ closing_delim_received = True
169
+ break
170
+ if read_attempts > frame_max_read_attempts:
171
+ print(f'WARNING: Dropped pkt with partial frame: {input}')
172
+ return None
173
+ chunk = ble_serial.read_until(expected=bytes([SLIP_END]))
174
+ if not chunk:
175
+ read_attempts += 1
176
+ continue
177
+ input += chunk
178
+
179
+ return input
101
180
 
102
- def read_from_ble(ble_serial):
103
- ble_serial_bytes = ble_serial.readline()
104
- input = ble_serial_bytes.decode("utf-8", "ignore").strip()
181
+ def read_from_ble(ble_serial: serial.Serial):
182
+ input = read_frame(ble_serial)
183
+ if input == None or len(input) == 0:
184
+ return None
185
+
186
+ input = slip_decode(input)
187
+ input_len = len(input)
188
+ if input_len > 3 and input[0] == UART_PKT_PREFIX_BYTE:
189
+ input = input[0:3].decode("utf-8", "ignore") + input[3:].hex().upper()
190
+ else:
191
+ input = input.decode("utf-8", "ignore").strip()
105
192
  # if input:
106
193
  # print(input)
107
194
  return input
@@ -155,7 +242,7 @@ def interference_analysis(ble_serial):
155
242
  print('\n' + '#' * 30 + f'\nAnalyzing channel {channel[0]}\n' + '#' * 30)
156
243
  # Send the sniffer a command to retrieve the counters and convert them to dict
157
244
  start_cntrs = get_pkts_cntrs(ble_serial, channel[0], set_rx_ch=True)
158
- cert_common.wait_time_n_print(CNTRS_LISTEN_TIME_SEC)
245
+ wait_time_n_print(CNTRS_LISTEN_TIME_SEC)
159
246
  end_cntrs = get_pkts_cntrs(ble_serial, channel[0])
160
247
 
161
248
  if start_cntrs is None or end_cntrs is None:
@@ -193,10 +280,6 @@ def on_unsubscribe(mqttc, userdata, mid):
193
280
  def on_message(client, userdata, message):
194
281
  data = json.loads(message.payload.decode("utf-8"))
195
282
  print_enable = True if not PIXEL_SIM_INDICATOR in str(message.payload.decode("utf-8")) else False
196
- # if print_enable:
197
- # print("##########\n// Message received at {}, topic={}:\n{}\n".format(datetime.datetime.now().strftime("%d/%m/%Y, %H:%M:%S"), message.topic, str(message.payload.decode("utf-8"))))
198
- # #TODO: logging print
199
- # # print("##########\n// Message received at {}, topic={}:\n{}\n".format(datetime.datetime.now().strftime("%d/%m/%Y, %H:%M:%S"), message.topic, str(message.payload.decode("utf-8"))))
200
283
  # Send packet to UART
201
284
  if TX_PKT in data:
202
285
  # Downlink packet
@@ -215,36 +298,54 @@ def on_message(client, userdata, message):
215
298
  # GW SIMULATOR
216
299
  ##############################################
217
300
  def parse_uart_pkts(input, mqttc, custom_broker, gw_id, seq_id):
218
- # 3 for p6, 12 for alias_brg_id, 62 for payload, 2 for rssi
301
+ # 3 for p6, 2 for rssi, 12 for alias_brg_id, 62 for payload
219
302
  if input.startswith("p6 ") and len(input) == (3 + 12 + 62 + 2):
220
- # p6 1234567898761E16C6FC0000EE02093E3C71BF6DFA3C006648001CB8003A730160000E010031
303
+ # p6 301234567898761E16C6FC0000EE02093E3C71BF6DFA3C006648001CB8003A730160000E0100
221
304
  pkt = UplinkPkt(gw_id, seq_id, input.split()[1])
222
305
  mqttc.publish(custom_broker[CUSTOM_BROKER_DATA_TOPIC], payload=json.dumps(pkt.dump(), indent=4))
223
306
  return True
224
- # 3 for p7, 12 for alias_brg_id, 78 for payload, 6 for side info, 2 for rssi
307
+ # 3 for p7, 2 for rssi, 12 for alias_brg_id, 78 for payload, 6 for side info
225
308
  elif input.startswith("p7 ") and len(input) == (3 + 12 + 78 + 6 + 2):
226
- # p7 1234567898762616C6FC05000002093E3C71BF6DFA3C006648001CB8003A730160000E0100112233445566778831
309
+ # p7 301234567898762616C6FC05000002093E3C71BF6DFA3C006648001CB8003A730160000E01001122334455667788
227
310
  pkt = UplinkExtendedPkt(gw_id, seq_id, input.split()[1])
228
311
  mqttc.publish(custom_broker[CUSTOM_BROKER_DATA_TOPIC], payload=json.dumps(pkt.dump(), indent=4))
229
312
  return True
313
+ # 3 for p8, 2 for rssi, 12 for alias_brg_id, the rest for payload of multiple packets
314
+ elif input.startswith("p8 "):
315
+ # p8 301234567898762616C6FC05000002093E3C71BF6DFA3C006648001CB8003A730160000E01001122334455667788....
316
+ pkt = UplinkAggregatedPkt(gw_id, seq_id, input.split()[1])
317
+ mqttc.publish(custom_broker[CUSTOM_BROKER_DATA_TOPIC], payload=json.dumps(pkt.dump(), indent=4))
318
+ return True
230
319
  elif GW_STATUS_MESSAGES:
231
320
  pkt = GW_STATUS_MESSAGES.pop(0)
232
321
  mqttc.publish(custom_broker[CUSTOM_BROKER_STATUS_TOPIC], payload=json.dumps(pkt, indent=4))
233
322
  return False
234
323
 
235
- def gw_sim_run(port, gw_id, analyze_interference=False):
324
+ def handle_cmds(input, ble_serial):
325
+ if input.startswith(RX_NORDIC_RECOVER_RESET):
326
+ utPrint(f"Simulator received reboot packet", "CYAN")
327
+ GW_SIM_RESET_TS = datetime.datetime.now()
328
+ write_to_ble(ble_serial, RESET_GW, sleep=0)
329
+ if input.startswith(RX_NORDIC_RECOVER_NORESET):
330
+ utPrint(f"Simulator recovered", "CYAN")
331
+ write_to_ble(ble_serial, f"{CONNECTIVITY_STATUS} 1 1")
236
332
 
237
- print(f"###>>> GW SIM STARTED WITH PORT {port}")
333
+ def gw_sim_run(port, gw_id, custom_broker, analyze_interference=False):
238
334
 
239
335
  # Init serial side
240
- print("\nAvailable ports:")
241
- for port, desc, hwid in sorted(serial.tools.list_ports.comports()):
242
- print("{}: {} [{}]".format(port, desc, hwid))
243
- ble_serial = serial.Serial(port=port, baudrate=921600, timeout=SERIAL_TIMEOUT)
336
+ if not port:
337
+ print("\nNo COM port given. Scanning for available ports:")
338
+ for port, desc, hwid in sorted(serial.tools.list_ports.comports()):
339
+ print("{}: {} [{}]".format(port, desc, hwid))
340
+ if not port:
341
+ print("\nNo available COM port found!")
342
+ sys.exit(-1)
343
+ print(f"###>>> GW SIM STARTED WITH PORT {port}")
344
+ ble_serial = serial.serial_for_url(url=port, baudrate=921600, timeout=SERIAL_TIMEOUT)
244
345
  ble_serial.flushInput()
245
346
 
246
347
  # Init mqtt side
247
- custom_broker = load_custom_broker(gw_id)
348
+ custom_broker = load_custom_broker(custom_broker, gw_id)
248
349
  client_id = '{}-republish2'.format(gw_id)
249
350
  userdata = {'serial': ble_serial}
250
351
  mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1, client_id, userdata=userdata)
@@ -282,10 +383,11 @@ def gw_sim_run(port, gw_id, analyze_interference=False):
282
383
  seq_id = 100
283
384
  while True:
284
385
  input = read_from_ble(ble_serial)
285
- if input and input[0] == "p" and input[2] == " ":
386
+ if input and len(input) >= 3 and input[0] == "p" and input[2] == " ":
286
387
  seq_id += 1
287
388
  # input = ""
288
- if not parse_uart_pkts(input, mqttc, custom_broker, gw_id, seq_id):
389
+ if input and not parse_uart_pkts(input, mqttc, custom_broker, gw_id, seq_id):
390
+ handle_cmds(input, ble_serial)
289
391
  # if input:
290
392
  if 0:
291
393
  print(f"###>>> IGNORED: {input}")
@@ -8,28 +8,40 @@ import datetime
8
8
  import base64
9
9
  import copy
10
10
  import traceback
11
- import brg_certificate.wltPb_pb2 as wpb
11
+ import common.wltPb_pb2 as wpb
12
12
  from google.protobuf.message import DecodeError
13
13
  from google.protobuf.json_format import MessageToDict
14
14
 
15
15
  # Local imports
16
- from brg_certificate.wlt_types import *
17
- from brg_certificate.cert_data_sim import PIXEL_SIM_INDICATOR, TAG_ID_OFFSET
18
- from brg_certificate.cert_prints import *
19
- from brg_certificate.cert_defines import *
16
+ from certificate.wlt_types import *
17
+ from certificate.cert_data_sim import PIXEL_SIM_INDICATOR, TAG_ID_OFFSET
18
+ from certificate.cert_prints import *
19
+ from certificate.cert_defines import *
20
20
 
21
21
 
22
22
  SENSORS_DATA_SI_DUP = 6
23
-
23
+ # Custom MQTT brokers' configuration jsons' paths
24
+ EMQX = os.path.join(BASE_DIR, "config/emqx.json")
25
+ WILIOT_DEV = os.path.join(BASE_DIR, "config/wiliot-dev.json")
24
26
  class WltMqttPkt:
25
27
  def __init__(self, body, topic, userdata):
26
28
  self.body = body
27
29
  self.mqtt_topic = topic
28
- self.mqtt_timestamp = datetime.datetime.now()
30
+ self.mqtt_timestamp = int(time.time() * 1000)
29
31
  self.body_ex = {}
30
32
  if "data" in self.mqtt_topic:
31
33
  self.body_ex = copy.deepcopy(body)
32
34
  self.body_ex['undecrypted'] = 0
35
+
36
+ # Split aggregated packets into multiple packets
37
+ split_pkts = []
38
+ for pkt in self.body_ex[PACKETS]:
39
+ if len(pkt[PAYLOAD])/2 > (int(pkt[PAYLOAD][0:2], 16) + 1): # Aggregated packet since the length is larger than the header length
40
+ split_pkts += split_aggregated_pkt(pkt)
41
+ else: # Not an aggregated packet
42
+ split_pkts += [pkt]
43
+ self.body_ex[PACKETS] = split_pkts
44
+
33
45
  for pkt in self.body_ex[PACKETS]:
34
46
  # if packet is not a mgmt packet or a side info packet it is a data packet
35
47
  wlt_pkt = WltPkt(pkt[PAYLOAD])
@@ -45,7 +57,12 @@ class WltMqttPkt:
45
57
  elif wlt_pkt.hdr.group_id == ag.GROUP_ID_SIDE_INFO_SENSOR:
46
58
  pkt[SIDE_INFO_SENSOR_PKT] = copy.deepcopy(wlt_pkt)
47
59
  elif wlt_pkt.hdr.uuid_lsb == ag.HDR_DEFAULT_BRG_SENSOR_UUID_LSB and wlt_pkt.hdr.uuid_msb == ag.HDR_DEFAULT_BRG_SENSOR_UUID_MSB:
48
- pkt[SENSOR_PKT] = copy.deepcopy(wlt_pkt)
60
+ if isinstance(wlt_pkt.pkt, ag.UnifiedSensorPkt):
61
+ pkt[UNIFIED_SENSOR_PKT] = copy.deepcopy(wlt_pkt)
62
+ if (wlt_pkt.hdr.group_id == ag.GROUP_ID_SIGNAL_INDICATOR):
63
+ pkt[UNIFIED_SENSOR_PKT].pkt.signal_indicator_payload = ag.SignalIndicatorDataV1(pkt[PAYLOAD][8:62])
64
+ else:
65
+ pkt[SENSOR_PKT] = copy.deepcopy(wlt_pkt)
49
66
  pkt[DECODED_DATA] = {TAG_ID: None, PACKET_CNTR: None, PACKET_TYPE: None}
50
67
  else:
51
68
  if userdata["data"] != DATA_SIMULATION:
@@ -91,7 +108,7 @@ class WltMqttPkts:
91
108
  self.status = []
92
109
 
93
110
  def local_resolve(p):
94
- import brg_certificate.ut.ut_resolve as ut_resolve
111
+ import certificate.ut.ut_resolve as ut_resolve
95
112
  irresolvable_payloads = ["1E16C6FC0000EE", "1E16AFFD0000EC", "1E16C6FC0000EC"]
96
113
  try:
97
114
  if any(substring in p for substring in irresolvable_payloads):
@@ -115,6 +132,39 @@ def local_resolve(p):
115
132
  print(e)
116
133
  print(f"Failed in local_resolve with packet: {p}\n")
117
134
  return None
135
+
136
+ def split_aggregated_pkt(pkt):
137
+ hex_str = pkt[PAYLOAD]
138
+ idx = 0
139
+ fragments = []
140
+
141
+ # walk through the hex string
142
+ while idx < len(hex_str):
143
+ # parse length byte
144
+ length = int(hex_str[idx:idx+2], 16)
145
+ if length < ag.HDR_DEFAULT_PKT_SIZE:
146
+ # The sensor packet itself is built from small segments, the smallest payload is of size 31 bytes
147
+ length = ag.HDR_DEFAULT_PKT_SIZE
148
+ end = idx + 2 + length*2
149
+ if end > len(hex_str):
150
+ raise ValueError(
151
+ f"Packet at position {idx} says {length} bytes, "
152
+ f"but only {(len(hex_str)-idx-2)//2} are available. pkt : {pkt[PAYLOAD]}"
153
+ )
154
+ # slice out this packet (including the length byte itself)
155
+ fragment = hex_str[idx:end]
156
+
157
+ # build new packet dict
158
+ fragments.append({
159
+ PAYLOAD: fragment,
160
+ TIMESTAMP: pkt[TIMESTAMP],
161
+ SEQUENCE_ID: pkt[SEQUENCE_ID],
162
+ RSSI: pkt[RSSI],
163
+ ALIAS_BRIDGE_ID: pkt[ALIAS_BRIDGE_ID],
164
+ AGGREGATED_PAYLOAD: pkt[PAYLOAD]
165
+ })
166
+ idx = end
167
+ return fragments
118
168
 
119
169
  def is_json(msg):
120
170
  is_utf = True
@@ -165,7 +215,7 @@ def on_message_protobuf(mqttc, userdata, message):
165
215
  pb_msg.ParseFromString(message.payload)
166
216
  pb_decoded = True
167
217
  except DecodeError as e:
168
- print(f'ERROR: failed decoding {message.topic} message: \n{e}\n')
218
+ print(f'ERROR: failed decoding {message.topic} message: {e}\npayload: {message.payload}')
169
219
 
170
220
  if pb_decoded is True:
171
221
  pb_msg_dict = MessageToDict(pb_msg)
@@ -178,6 +228,7 @@ def on_message_protobuf(mqttc, userdata, message):
178
228
  for idx, id in enumerate(ids_list):
179
229
  ids_list[idx] = base64.b64decode(id).hex().upper()
180
230
  if 'data' in message.topic and PACKETS in pb_msg_dict.keys():
231
+ pb_msg_dict[TIMESTAMP] = (int(pb_msg_dict[TIMESTAMP]))
181
232
  for idx, pkt in enumerate(pb_msg_dict[PACKETS]):
182
233
  pb_msg_dict[PACKETS][idx][PAYLOAD] = base64.b64decode(pkt[PAYLOAD]).hex().upper()
183
234
  pb_msg_dict[PACKETS][idx][TIMESTAMP] = int(pkt[TIMESTAMP])
@@ -196,37 +247,36 @@ def on_message_protobuf(mqttc, userdata, message):
196
247
  def pkts_to_log(pkts):
197
248
  text = ""
198
249
  for p in pkts:
199
- text += "// {} topic={}".format(p.mqtt_timestamp.strftime("%d/%m/%Y, %H:%M:%S"), p.mqtt_topic)
250
+ dt = datetime.datetime.fromtimestamp(p.mqtt_timestamp / 1000)
251
+ text += "// {} topic={}".format(dt.strftime("%d/%m/%Y, %H:%M:%S"), p.mqtt_topic)
200
252
  text += "\n"+json.dumps(p.body, indent=4)+"\n"
201
253
  return text
202
254
 
203
- def write_to_log_file(file_name, pkts):
204
- f = open(os.path.join(BASE_DIR, file_name), "w")
205
- f.write(pkts_to_log(pkts))
206
- f.close()
255
+ def write_pkts_to_log_file(file, pkts):
256
+ write_to_log_file(file, pkts_to_log(pkts), "w")
207
257
 
208
258
  def write_to_mqtt_log_file(txt):
209
- f = open(os.path.join(BASE_DIR, CERT_MQTT_LOG_FILE), "a")
210
- f.write(txt)
211
- f.close()
212
-
213
- def load_custom_broker(gw, rel_path="."):
214
- f = open(os.path.join(BASE_DIR, rel_path, "config", "eclipse.json"))
215
- # f = open(os.path.join(BASE_DIR, rel_path, "config", "hivemq.json"))
216
- # f = open(os.path.join(BASE_DIR, rel_path, "config", "mosquitto.json"))
217
- # f = open(os.path.join(BASE_DIR, rel_path, "config", "wiliot-dev.json"))
259
+ write_to_log_file(CERT_MQTT_LOG_FILE, txt, "a")
260
+
261
+ def load_custom_broker(broker_filepath, gw):
262
+ try:
263
+ f = open(str(broker_filepath).strip("'"))
264
+ except FileNotFoundError:
265
+ raise FileNotFoundError(f"No such file: {broker_filepath}")
218
266
  data = json.load(f)
219
267
  data[CUSTOM_BROKER_UPDATE_TOPIC] += gw
220
268
  data[CUSTOM_BROKER_STATUS_TOPIC] += gw
221
269
  data[CUSTOM_BROKER_DATA_TOPIC] += gw
222
270
  return data
223
271
 
224
- def mqttc_init(gw_id, userdata={PKTS: WltMqttPkts()}, rel_path=".", data=DATA_REAL_TAGS):
225
-
226
- custom_broker = load_custom_broker(gw=gw_id, rel_path=rel_path)
272
+ def mqttc_init(gw_id, custom_broker, data=DATA_REAL_TAGS):
273
+ # Ensure each MQTT client gets its own userdata for logging and getting pkts
274
+ userdata = {PKTS: WltMqttPkts()}
275
+ custom_broker = load_custom_broker(broker_filepath=custom_broker, gw=gw_id)
227
276
  client_id = '{}-republish'.format(gw_id)
228
277
  userdata["data"] = data
229
278
  mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1, client_id, userdata=userdata)
279
+ print(f"Connecting to MQTT broker at {custom_broker[CUSTOM_BROKER_BROKER_URL]}:{custom_broker[CUSTOM_BROKER_PORT]} with client ID: {client_id}")
230
280
  mqttc.username_pw_set(custom_broker[CUSTOM_BROKER_USERNAME], custom_broker[CUSTOM_BROKER_PASSWORD])
231
281
  mqttc.on_message = on_message
232
282
  mqttc.on_connect = on_connect
@@ -240,10 +290,13 @@ def mqttc_init(gw_id, userdata={PKTS: WltMqttPkts()}, rel_path=".", data=DATA_RE
240
290
 
241
291
  mqttc.update_topic = custom_broker[CUSTOM_BROKER_UPDATE_TOPIC]
242
292
  mqttc.subscribe(mqttc.update_topic)
293
+ print(f"Subscribed to update topic: {mqttc.update_topic}")
243
294
  mqttc.data_topic = custom_broker[CUSTOM_BROKER_DATA_TOPIC]
244
295
  mqttc.subscribe(mqttc.data_topic)
296
+ print(f"Subscribed to data topic: {mqttc.data_topic}")
245
297
  mqttc.status_topic = custom_broker[CUSTOM_BROKER_STATUS_TOPIC]
246
298
  mqttc.subscribe(mqttc.status_topic)
299
+ print(f"Subscribed to status topic: {mqttc.status_topic}")
247
300
 
248
301
  mqttc.flush_pkts = mqttc._userdata[PKTS].flush
249
302
  mqttc.flush_data_pkts = mqttc._userdata[PKTS].flush_data
@@ -252,33 +305,65 @@ def mqttc_init(gw_id, userdata={PKTS: WltMqttPkts()}, rel_path=".", data=DATA_RE
252
305
 
253
306
  return mqttc
254
307
 
255
- def dump_pkts(test, log):
256
- write_to_log_file(os.path.join(test.dir, MQTT_LOG_PRE_STR+log+"_all.json"), test.mqttc._userdata[PKTS].all)
257
- write_to_log_file(os.path.join(test.dir, MQTT_LOG_PRE_STR+log+"_data.json"), test.mqttc._userdata[PKTS].data)
258
- write_to_log_file(os.path.join(test.dir, MQTT_LOG_PRE_STR+log+"_status.json"), test.mqttc._userdata[PKTS].status)
259
- write_to_log_file(os.path.join(test.dir, MQTT_LOG_PRE_STR+log+"_update.json"), test.mqttc._userdata[PKTS].update)
308
+ def dump_pkts(test, log, target=DUT):
309
+ mqttc = test.get_mqttc_by_target(target)
310
+ write_pkts_to_log_file(os.path.join(test.dir, MQTT_LOG_PRE_STR+log+"_all.json"), mqttc._userdata[PKTS].all)
311
+ write_pkts_to_log_file(os.path.join(test.dir, MQTT_LOG_PRE_STR+log+"_data.json"), mqttc._userdata[PKTS].data)
312
+ write_pkts_to_log_file(os.path.join(test.dir, MQTT_LOG_PRE_STR+log+"_status.json"), mqttc._userdata[PKTS].status)
313
+ write_pkts_to_log_file(os.path.join(test.dir, MQTT_LOG_PRE_STR+log+"_update.json"), mqttc._userdata[PKTS].update)
314
+
315
+ def generate_log_file(test, val, target=DUT):
316
+ if type(val) == int or type(val) == str:
317
+ log_string = str(val)
318
+ else:
319
+ log_string = str(val[0])
320
+ for i in range(1,len(val)):
321
+ log_string += ","+ str(val[i])
322
+ if test.internal_brg:
323
+ log_string += "_internal_brg"
324
+ dump_pkts(test, log_string, target)
325
+
326
+ def mqtt_scan_n_create_log_file(test, duration, phase, target=DUT):
327
+ test.flush_all_mqtt_packets()
328
+ mqtt_scan_wait(test, duration=duration, target=target)
329
+ generate_log_file(test, phase, DUT)
330
+ generate_log_file(test, phase + "_tester", TESTER)
260
331
 
261
332
  # Get data/tags functions
262
- def get_all_data_pkts(mqttc):
333
+ def get_all_data_pkts(mqttc, indicator=None):
263
334
  data_pkts = []
335
+ gw_id = mqttc.update_topic.split("/")[-1]
264
336
  for p in mqttc._userdata[PKTS].data:
265
- gw_id = p.body_ex[GW_ID] if GW_ID in p.body_ex else ""
266
337
  if PACKETS in p.body_ex:
267
338
  for pkt in p.body_ex[PACKETS]:
339
+ if indicator and indicator not in pkt[PAYLOAD]: continue
268
340
  pkt[GW_ID] = gw_id
269
341
  data_pkts += [pkt]
270
342
  return data_pkts
271
343
 
272
- def get_all_sim_data_pkts(mqttc):
273
- data_pkts = []
344
+ def get_all_aggregated_data_pkts(mqttc, indicator =""):
345
+ aggregated_data_pkts = []
346
+ seen_aggregated_payloads = set()
347
+ gw_id = mqttc.update_topic.split("/")[-1]
274
348
  for p in mqttc._userdata[PKTS].data:
275
- gw_id = p.body_ex[GW_ID] if GW_ID in p.body_ex else ""
276
349
  if PACKETS in p.body_ex:
277
350
  for pkt in p.body_ex[PACKETS]:
278
- if PIXEL_SIM_INDICATOR in pkt[PAYLOAD]:
279
- pkt[GW_ID] = gw_id
280
- data_pkts += [pkt]
281
- return data_pkts
351
+ if indicator and indicator not in pkt[PAYLOAD]: continue
352
+ if AGGREGATED_PAYLOAD in pkt:
353
+ # Deduplicate based on AGGREGATED_PAYLOAD (since for each packet in the aggregated packet, we have another element with the same AGGREGATED_PAYLOAD)
354
+ aggregated_payload = pkt[AGGREGATED_PAYLOAD]
355
+ if aggregated_payload not in seen_aggregated_payloads:
356
+ seen_aggregated_payloads.add(aggregated_payload)
357
+ pkt[GW_ID] = gw_id
358
+ aggregated_data_pkts += [pkt]
359
+ return aggregated_data_pkts
360
+
361
+ def get_all_status_pkts(mqttc, status_type=None):
362
+ status_pkts = []
363
+ for p in mqttc._userdata[PKTS].status:
364
+ if status_type and status_type not in p.body: continue
365
+ status_pkts += [p.body]
366
+ return status_pkts
282
367
 
283
368
  def get_undecrypted_data_pkts_count(mqttc):
284
369
  undecrypted = 0
@@ -287,13 +372,30 @@ def get_undecrypted_data_pkts_count(mqttc):
287
372
  undecrypted += p.body_ex['undecrypted']
288
373
  return undecrypted
289
374
 
290
- def get_all_sensor_pkts(test, is_embedded=False):
291
- all_sensor_pkts = couple_sensor_data_si_coupling(test)
292
- all_sensor_pkts = [p for p in all_sensor_pkts if test.active_brg.id_str == p[BRIDGE_ID] and (p[IS_EMBEDDED] == is_embedded)]
375
+ def get_embedded_sensor_pkts(sensor_pkts):
376
+ embedded_sensor_pkts = []
377
+ embedded_sensor_uuid_list = [ag.SENSOR_SERVICE_ID_BATTERY_SENSOR, ag.SENSOR_SERVICE_ID_LIS2DW12, ag.SENSOR_SERVICE_ID_POF_DATA]
378
+ for uuid in embedded_sensor_uuid_list:
379
+ for p in sensor_pkts:
380
+ _uuid = (f"{p[UNIFIED_SENSOR_PKT].pkt.sensor_ad_type:02X}"
381
+ f"{p[UNIFIED_SENSOR_PKT].pkt.sensor_uuid_msb:02X}"
382
+ f"{p[UNIFIED_SENSOR_PKT].pkt.sensor_uuid_lsb:02X}")
383
+ if UNIFIED_SENSOR_PKT in p and (f"{uuid:06X}" == f"{_uuid}"):
384
+ embedded_sensor_pkts += [p]
385
+ return embedded_sensor_pkts
386
+
387
+ def get_all_sensor_pkts(test, is_unified=False, remove_embedded=False, target=DUT):
388
+ all_pkts = get_all_data_pkts(test.get_mqttc_by_target(target))
389
+ all_unified_sensor_pkts = [p for p in all_pkts if UNIFIED_SENSOR_PKT in p and test.active_brg.id_alias == p[ALIAS_BRIDGE_ID]
390
+ and is_unified]
391
+ all_coupled_sensor_pkts = couple_sensor_data_si_coupling(test, all_pkts)
392
+ all_sensor_pkts = [p for p in all_coupled_sensor_pkts if test.active_brg.id_str == p[BRIDGE_ID]] + all_unified_sensor_pkts
393
+ if remove_embedded:
394
+ embedded_sensor_pkts = get_embedded_sensor_pkts(all_unified_sensor_pkts)
395
+ all_sensor_pkts = [p for p in all_sensor_pkts if p not in embedded_sensor_pkts]
293
396
  return all_sensor_pkts
294
397
 
295
- def couple_sensor_data_si_coupling(test):
296
- all_pkts = get_all_data_pkts(test.mqttc)
398
+ def couple_sensor_data_si_coupling(test, all_pkts):
297
399
  all_sensor_data_pkts = [p for p in all_pkts if SENSOR_PKT in p]
298
400
  all_sensor_side_info_pkts = [p for p in all_pkts if SIDE_INFO_SENSOR_PKT in p]
299
401
  # Couple data and side info
@@ -342,27 +444,29 @@ def count_pkt_id_duplications(test, all_sensor_data_pkts, all_sensor_side_info_p
342
444
  #TODO: logging print(debug)
343
445
  # test.reason = f'Warning: {coupled_pkt[PKT_ID_CTR]} sensor data and si with pkt id 0x{_pkt_id:08X}'
344
446
 
345
- def get_all_brg1_ext_sensor_pkts(test=None):
447
+ def get_all_brg1_ext_sensor_pkts(test=None, is_unified=False, target=DUT):
448
+ original_active_brg = test.active_brg
346
449
  test.active_brg = test.brg1
347
- pkts = get_all_sensor_pkts(test)
348
- test.active_brg = test.brg0
450
+ pkts = get_all_sensor_pkts(test, is_unified, target=target)
451
+ test.active_brg = original_active_brg
349
452
  return pkts
350
453
 
351
454
  def get_all_custom_pkts(test=None):
352
- return get_all_sensor_pkts(test, is_embedded=True)
455
+ return get_all_sensor_pkts(test, is_unified=True)
353
456
 
354
- def get_all_mgmt_pkts(mqttc):
355
- all_data_pkts = get_all_data_pkts(mqttc)
457
+ def get_all_mgmt_pkts(mqttc, indicator=""):
458
+ all_data_pkts = get_all_data_pkts(mqttc, indicator)
356
459
  return [p for p in all_data_pkts if MGMT_PKT in p]
357
460
 
358
- def get_brg2gw_mgmt_pkts(mqttc, test=None, mgmt_types=[]):
461
+ def get_brg2gw_mgmt_pkts(mqttc, brg, mgmt_types=[]):
359
462
  brg2gw_mgmt_pkts = [p for p in get_all_mgmt_pkts(mqttc) if ((p[MGMT_PKT].hdr.group_id == ag.GROUP_ID_BRG2GW) and
360
463
  (not mgmt_types or type(p[MGMT_PKT].pkt) in mgmt_types))]
361
- pkts = [p for p in brg2gw_mgmt_pkts if test.active_brg.id_str in p[PAYLOAD]]
464
+ pkts = [p for p in brg2gw_mgmt_pkts if brg.id_str in p[PAYLOAD]]
362
465
  return pkts
363
466
 
364
- def get_unified_data_pkts(test, only_active_brg=True):
365
- all_unified_pkts, pkts = [], get_all_sim_data_pkts(test.mqttc) if test.data == DATA_SIMULATION else get_all_data_pkts(test.mqttc)
467
+ def get_unified_data_pkts(test, only_active_brg=True, target=DUT, indicator=PIXEL_SIM_INDICATOR):
468
+ mqttc = test.get_mqttc_by_target(target)
469
+ all_unified_pkts, pkts = [], get_all_data_pkts(mqttc, indicator) if test.data == DATA_SIMULATION else get_all_data_pkts(mqttc)
366
470
  for p in pkts:
367
471
  if UNIFIED_PKT in p:
368
472
  all_unified_pkts += [p]
@@ -372,11 +476,12 @@ def get_unified_data_pkts(test, only_active_brg=True):
372
476
  print(f"\nCollected {len(pkts)} unified data pkts")
373
477
  return pkts
374
478
 
375
- def get_internal_brg_unified_data_pkts(test):
376
- all_unified_pkts, pkts = [], get_all_sim_data_pkts(test.mqttc) if test.data == DATA_SIMULATION else get_all_data_pkts(test.mqttc)
479
+ def get_internal_brg_unified_data_pkts(test, target=DUT):
480
+ mqttc = test.get_mqttc_by_target(target)
481
+ all_unified_pkts, pkts = [], get_all_data_pkts(mqttc, indicator=PIXEL_SIM_INDICATOR) if test.data == DATA_SIMULATION else get_all_data_pkts(mqttc)
377
482
  for p in pkts:
378
483
  if UNIFIED_PKT in p:
379
484
  all_unified_pkts += [p]
380
485
  pkts = [p for p in all_unified_pkts if p[ALIAS_BRIDGE_ID] == test.internal_id_alias()]
381
486
  print(f"\nCollected {len(pkts)} unified gw_tag_pkts")
382
- return pkts
487
+ return pkts