wiliot-certificate 4.4.3__py3-none-any.whl → 4.5.0__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 (297) 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. certificate/cert_common.py +1488 -0
  4. certificate/cert_config.py +480 -0
  5. {brg_certificate → certificate}/cert_data_sim.py +134 -46
  6. {brg_certificate → certificate}/cert_defines.py +129 -128
  7. {brg_certificate → certificate}/cert_gw_sim.py +183 -53
  8. {brg_certificate → certificate}/cert_mqtt.py +179 -64
  9. {brg_certificate → certificate}/cert_prints.py +35 -33
  10. {brg_certificate → certificate}/cert_protobuf.py +15 -6
  11. {brg_certificate → certificate}/cert_results.py +240 -64
  12. certificate/cert_utils.py +634 -0
  13. certificate/certificate.py +205 -0
  14. certificate/certificate_cli.py +76 -0
  15. certificate/certificate_eth_test_list.txt +76 -0
  16. certificate/certificate_sanity_test_list.txt +66 -0
  17. certificate/certificate_test_list.txt +76 -0
  18. {brg_certificate → certificate}/tests/calibration/interval_test/interval_test.json +3 -2
  19. {brg_certificate → certificate}/tests/calibration/interval_test/interval_test.py +7 -6
  20. certificate/tests/calibration/output_power_test/output_power_test.json +23 -0
  21. certificate/tests/calibration/output_power_test/output_power_test.py +39 -0
  22. {brg_certificate → certificate}/tests/calibration/pattern_test/pattern_test.json +2 -1
  23. {brg_certificate → certificate}/tests/calibration/pattern_test/pattern_test.py +20 -15
  24. certificate/tests/cloud_connectivity/acl_ext_adv_test/acl_ext_adv_test.json +15 -0
  25. certificate/tests/cloud_connectivity/acl_ext_adv_test/acl_ext_adv_test.py +140 -0
  26. certificate/tests/cloud_connectivity/acl_test/acl_test.json +15 -0
  27. certificate/tests/cloud_connectivity/acl_test/acl_test.py +96 -0
  28. certificate/tests/cloud_connectivity/brg_ota_test/brg_ota_test.json +19 -0
  29. certificate/tests/cloud_connectivity/brg_ota_test/brg_ota_test.py +41 -0
  30. certificate/tests/cloud_connectivity/channel_scan_behaviour_test/channel_scan_behaviour_test.json +19 -0
  31. certificate/tests/cloud_connectivity/channel_scan_behaviour_test/channel_scan_behaviour_test.py +215 -0
  32. certificate/tests/cloud_connectivity/connection_test/connection_test.json +18 -0
  33. certificate/tests/cloud_connectivity/connection_test/connection_test.py +67 -0
  34. certificate/tests/cloud_connectivity/deduplication_test/deduplication_test.json +15 -0
  35. certificate/tests/cloud_connectivity/deduplication_test/deduplication_test.py +80 -0
  36. certificate/tests/cloud_connectivity/downlink_test/downlink_test.json +21 -0
  37. certificate/tests/cloud_connectivity/downlink_test/downlink_test.py +201 -0
  38. certificate/tests/cloud_connectivity/ext_adv_stress_test/ext_adv_stress_test.json +17 -0
  39. certificate/tests/cloud_connectivity/ext_adv_stress_test/ext_adv_stress_test.py +104 -0
  40. certificate/tests/cloud_connectivity/reboot_test/reboot_test.json +18 -0
  41. certificate/tests/cloud_connectivity/reboot_test/reboot_test.py +59 -0
  42. certificate/tests/cloud_connectivity/registration_test/registration_test.json +20 -0
  43. certificate/tests/cloud_connectivity/registration_test/registration_test.py +384 -0
  44. certificate/tests/cloud_connectivity/registration_test/registration_test_cli.py +90 -0
  45. certificate/tests/cloud_connectivity/stress_test/stress_test.json +17 -0
  46. certificate/tests/cloud_connectivity/stress_test/stress_test.py +101 -0
  47. certificate/tests/cloud_connectivity/uplink_ext_adv_test/uplink_ext_adv_test.json +25 -0
  48. certificate/tests/cloud_connectivity/uplink_ext_adv_test/uplink_ext_adv_test.py +92 -0
  49. certificate/tests/cloud_connectivity/uplink_test/uplink_test.json +20 -0
  50. certificate/tests/cloud_connectivity/uplink_test/uplink_test.py +169 -0
  51. {brg_certificate → certificate}/tests/datapath/aging_test/aging_test.json +2 -1
  52. certificate/tests/datapath/aging_test/aging_test.py +142 -0
  53. certificate/tests/datapath/event_ble5_test/event_ble5_test.json +17 -0
  54. certificate/tests/datapath/event_ble5_test/event_ble5_test.py +89 -0
  55. certificate/tests/datapath/event_test/event_test.json +17 -0
  56. certificate/tests/datapath/event_test/event_test.py +80 -0
  57. {brg_certificate → certificate}/tests/datapath/num_of_tags_test/num_of_tags_test.json +4 -3
  58. {brg_certificate → certificate}/tests/datapath/num_of_tags_test/num_of_tags_test.py +19 -13
  59. certificate/tests/datapath/output_power_test/output_power_test.json +23 -0
  60. {brg_certificate → certificate}/tests/datapath/output_power_test/output_power_test.py +17 -6
  61. {brg_certificate → certificate}/tests/datapath/pacer_interval_ble5_test/pacer_interval_ble5_test.json +2 -1
  62. {brg_certificate → certificate}/tests/datapath/pacer_interval_ble5_test/pacer_interval_ble5_test.py +13 -11
  63. {brg_certificate → certificate}/tests/datapath/pacer_interval_test/pacer_interval_test.json +2 -1
  64. {brg_certificate → certificate}/tests/datapath/pacer_interval_test/pacer_interval_test.py +9 -7
  65. {brg_certificate → certificate}/tests/datapath/pattern_test/pattern_test.json +3 -2
  66. {brg_certificate → certificate}/tests/datapath/pattern_test/pattern_test.py +18 -6
  67. certificate/tests/datapath/pkt_filter_ble5_chl21_test/pkt_filter_ble5_chl21_test.json +20 -0
  68. certificate/tests/datapath/pkt_filter_ble5_chl21_test/pkt_filter_ble5_chl21_test.py +61 -0
  69. {brg_certificate → certificate}/tests/datapath/pkt_filter_ble5_test/pkt_filter_ble5_test.json +2 -1
  70. {brg_certificate → certificate}/tests/datapath/pkt_filter_ble5_test/pkt_filter_ble5_test.py +15 -14
  71. certificate/tests/datapath/pkt_filter_brg2gw_ext_adv_test/pkt_filter_brg2gw_ext_adv_test.json +19 -0
  72. certificate/tests/datapath/pkt_filter_brg2gw_ext_adv_test/pkt_filter_brg2gw_ext_adv_test.py +85 -0
  73. {brg_certificate → certificate}/tests/datapath/pkt_filter_gen3_test/pkt_filter_gen3_test.json +2 -1
  74. {brg_certificate → certificate}/tests/datapath/pkt_filter_gen3_test/pkt_filter_gen3_test.py +10 -9
  75. {brg_certificate → certificate}/tests/datapath/pkt_filter_test/pkt_filter_test.json +2 -1
  76. {brg_certificate → certificate}/tests/datapath/pkt_filter_test/pkt_filter_test.py +10 -9
  77. {brg_certificate → certificate}/tests/datapath/rssi_threshold_test/rssi_threshold_test.json +3 -2
  78. {brg_certificate → certificate}/tests/datapath/rssi_threshold_test/rssi_threshold_test.py +9 -8
  79. brg_certificate/tests/datapath/output_power_test/output_power_test.json → certificate/tests/datapath/rx_channel_hopping_test/rx_channel_hopping_test.json +6 -4
  80. certificate/tests/datapath/rx_channel_hopping_test/rx_channel_hopping_test.py +77 -0
  81. {brg_certificate → certificate}/tests/datapath/rx_channel_test/rx_channel_test.json +3 -2
  82. {brg_certificate → certificate}/tests/datapath/rx_channel_test/rx_channel_test.py +7 -6
  83. {brg_certificate → certificate}/tests/datapath/rx_rate_gen2_test/rx_rate_gen2_test.json +8 -7
  84. {brg_certificate → certificate}/tests/datapath/rx_rate_gen2_test/rx_rate_gen2_test.py +113 -73
  85. {brg_certificate → certificate}/tests/datapath/rx_rate_gen3_test/rx_rate_gen3_test.json +8 -7
  86. {brg_certificate → certificate}/tests/datapath/rx_rate_gen3_test/rx_rate_gen3_test.py +112 -72
  87. {brg_certificate → certificate}/tests/datapath/stress_gen3_test/stress_gen3_test.json +4 -3
  88. {brg_certificate → certificate}/tests/datapath/stress_gen3_test/stress_gen3_test.py +15 -11
  89. {brg_certificate → certificate}/tests/datapath/stress_test/stress_test.json +4 -3
  90. {brg_certificate → certificate}/tests/datapath/stress_test/stress_test.py +15 -11
  91. {brg_certificate → certificate}/tests/datapath/tx_repetition_test/tx_repetition_test.json +3 -1
  92. {brg_certificate → certificate}/tests/datapath/tx_repetition_test/tx_repetition_test.py +14 -13
  93. certificate/tests/edge_mgmt/action_blink_test/action_blink_test.json +15 -0
  94. certificate/tests/edge_mgmt/action_blink_test/action_blink_test.py +24 -0
  95. certificate/tests/edge_mgmt/action_get_battery_sensor_test/action_get_battery_sensor_test.json +15 -0
  96. certificate/tests/edge_mgmt/action_get_battery_sensor_test/action_get_battery_sensor_test.py +43 -0
  97. certificate/tests/edge_mgmt/action_get_module_test/action_get_module_test.json +15 -0
  98. certificate/tests/edge_mgmt/action_get_module_test/action_get_module_test.py +42 -0
  99. certificate/tests/edge_mgmt/action_get_pof_data_test/action_get_pof_data_test.json +15 -0
  100. certificate/tests/edge_mgmt/action_get_pof_data_test/action_get_pof_data_test.py +44 -0
  101. certificate/tests/edge_mgmt/action_gw_hb_test/action_gw_hb_test.json +16 -0
  102. certificate/tests/edge_mgmt/action_gw_hb_test/action_gw_hb_test.py +42 -0
  103. certificate/tests/edge_mgmt/action_reboot_test/action_reboot_test.json +15 -0
  104. certificate/tests/edge_mgmt/action_reboot_test/action_reboot_test.py +49 -0
  105. certificate/tests/edge_mgmt/action_restore_defaults_test/action_restore_defaults_test.json +15 -0
  106. certificate/tests/edge_mgmt/action_restore_defaults_test/action_restore_defaults_test.py +102 -0
  107. certificate/tests/edge_mgmt/action_send_hb_test/action_send_hb_test.json +15 -0
  108. certificate/tests/edge_mgmt/action_send_hb_test/action_send_hb_test.py +45 -0
  109. {brg_certificate → certificate}/tests/edge_mgmt/periodic_msgs_test/periodic_msgs_test.json +3 -2
  110. {brg_certificate → certificate}/tests/edge_mgmt/periodic_msgs_test/periodic_msgs_test.py +22 -11
  111. {brg_certificate → certificate}/tests/energy2400/duty_cycle_test/duty_cycle_test.json +2 -1
  112. {brg_certificate → certificate}/tests/energy2400/duty_cycle_test/duty_cycle_test.py +7 -6
  113. certificate/tests/energy2400/output_power_test/output_power_test.json +23 -0
  114. {brg_certificate → certificate}/tests/energy2400/output_power_test/output_power_test.py +17 -6
  115. {brg_certificate → certificate}/tests/energy2400/pattern_test/pattern_test.json +2 -1
  116. {brg_certificate → certificate}/tests/energy2400/pattern_test/pattern_test.py +7 -6
  117. certificate/tests/energy2400/signal_indicator_ble5_test/signal_indicator_ble5_test.json +26 -0
  118. certificate/tests/energy2400/signal_indicator_ble5_test/signal_indicator_ble5_test.py +379 -0
  119. certificate/tests/energy2400/signal_indicator_ext_adv_test/signal_indicator_ext_adv_test.json +20 -0
  120. certificate/tests/energy2400/signal_indicator_ext_adv_test/signal_indicator_ext_adv_test.py +173 -0
  121. certificate/tests/energy2400/signal_indicator_test/signal_indicator_test.json +24 -0
  122. certificate/tests/energy2400/signal_indicator_test/signal_indicator_test.py +350 -0
  123. {brg_certificate → certificate}/tests/energy_sub1g/duty_cycle_test/duty_cycle_test.json +2 -1
  124. {brg_certificate → certificate}/tests/energy_sub1g/duty_cycle_test/duty_cycle_test.py +7 -6
  125. {brg_certificate → certificate}/tests/energy_sub1g/pattern_test/pattern_test.json +2 -1
  126. {brg_certificate → certificate}/tests/energy_sub1g/pattern_test/pattern_test.py +7 -6
  127. {brg_certificate → certificate}/tests/pwr_mgmt/pwr_mgmt_test/pwr_mgmt_test.json +2 -1
  128. {brg_certificate → certificate}/tests/pwr_mgmt/pwr_mgmt_test/pwr_mgmt_test.py +10 -10
  129. {brg_certificate → certificate}/tests/sensors/ext_sensor_test/ext_sensor_test.json +5 -4
  130. certificate/tests/sensors/ext_sensor_test/ext_sensor_test.py +450 -0
  131. certificate/wlt_types.py +122 -0
  132. {gw_certificate → common}/api_if/202/status.json +6 -0
  133. {gw_certificate → common}/api_if/203/status.json +6 -0
  134. {gw_certificate → common}/api_if/204/status.json +6 -0
  135. common/api_if/206/data.json +85 -0
  136. common/api_if/206/status.json +69 -0
  137. common/api_if/api_validation.py +91 -0
  138. common/web/templates/generator.html +210 -0
  139. common/web/templates/index.html +20 -0
  140. common/web/templates/menu.html +54 -0
  141. common/web/templates/parser.html +53 -0
  142. {brg_certificate/ag → common/web/templates}/wlt_types.html +1216 -191
  143. common/web/web_utils.py +399 -0
  144. {brg_certificate → common}/wltPb_pb2.py +14 -12
  145. {gw_certificate/common → common}/wltPb_pb2.pyi +16 -2
  146. gui_certificate/gui_certificate_cli.py +14 -0
  147. gui_certificate/server.py +1267 -0
  148. gui_certificate/templates/cert_run.html +1273 -0
  149. wiliot_certificate-4.5.0.dist-info/METADATA +99 -0
  150. wiliot_certificate-4.5.0.dist-info/RECORD +168 -0
  151. {wiliot_certificate-4.4.3.dist-info → wiliot_certificate-4.5.0.dist-info}/WHEEL +1 -1
  152. wiliot_certificate-4.5.0.dist-info/entry_points.txt +5 -0
  153. wiliot_certificate-4.5.0.dist-info/top_level.txt +3 -0
  154. brg_certificate/ag/energous_v0_defines.py +0 -925
  155. brg_certificate/ag/energous_v1_defines.py +0 -931
  156. brg_certificate/ag/energous_v2_defines.py +0 -925
  157. brg_certificate/ag/energous_v3_defines.py +0 -925
  158. brg_certificate/ag/energous_v4_defines.py +0 -925
  159. brg_certificate/ag/fanstel_lan_v0_defines.py +0 -925
  160. brg_certificate/ag/fanstel_lte_v0_defines.py +0 -925
  161. brg_certificate/ag/fanstel_wifi_v0_defines.py +0 -925
  162. brg_certificate/ag/minew_lte_v0_defines.py +0 -925
  163. brg_certificate/ag/wlt_types_ag_jsons/brg2brg_ota.json +0 -142
  164. brg_certificate/ag/wlt_types_ag_jsons/brg2gw_hb.json +0 -785
  165. brg_certificate/ag/wlt_types_ag_jsons/brg2gw_hb_sleep.json +0 -139
  166. brg_certificate/ag/wlt_types_ag_jsons/calibration.json +0 -394
  167. brg_certificate/ag/wlt_types_ag_jsons/custom.json +0 -515
  168. brg_certificate/ag/wlt_types_ag_jsons/datapath.json +0 -672
  169. brg_certificate/ag/wlt_types_ag_jsons/energy2400.json +0 -550
  170. brg_certificate/ag/wlt_types_ag_jsons/energySub1g.json +0 -595
  171. brg_certificate/ag/wlt_types_ag_jsons/externalSensor.json +0 -598
  172. brg_certificate/ag/wlt_types_ag_jsons/interface.json +0 -938
  173. brg_certificate/ag/wlt_types_ag_jsons/powerManagement.json +0 -1234
  174. brg_certificate/ag/wlt_types_ag_jsons/side_info_sensor.json +0 -105
  175. brg_certificate/ag/wlt_types_ag_jsons/signal_indicator_data.json +0 -77
  176. brg_certificate/ag/wlt_types_ag_jsons/unified_echo_ext_pkt.json +0 -61
  177. brg_certificate/ag/wlt_types_ag_jsons/unified_echo_pkt.json +0 -110
  178. brg_certificate/brg_certificate.py +0 -225
  179. brg_certificate/brg_certificate_cli.py +0 -63
  180. brg_certificate/cert_common.py +0 -923
  181. brg_certificate/cert_config.py +0 -402
  182. brg_certificate/cert_utils.py +0 -362
  183. brg_certificate/certificate_bcc_sanity_test_list.txt +0 -40
  184. brg_certificate/certificate_bcc_test_list.txt +0 -48
  185. brg_certificate/certificate_sanity_test_list.txt +0 -43
  186. brg_certificate/certificate_test_list.txt +0 -53
  187. brg_certificate/config/eclipse.json +0 -10
  188. brg_certificate/config/hivemq.json +0 -10
  189. brg_certificate/config/mosquitto.json +0 -10
  190. brg_certificate/config/mosquitto.md +0 -95
  191. brg_certificate/config/wiliot-dev.json +0 -10
  192. brg_certificate/restore_brg.py +0 -61
  193. brg_certificate/tests/calibration/output_power_test/output_power_test.json +0 -16
  194. brg_certificate/tests/calibration/output_power_test/output_power_test.py +0 -28
  195. brg_certificate/tests/datapath/aging_test/aging_test.py +0 -143
  196. brg_certificate/tests/datapath/pacer_interval_tags_count_test/pacer_interval_tags_count_test.json +0 -16
  197. brg_certificate/tests/datapath/pacer_interval_tags_count_test/pacer_interval_tags_count_test.py +0 -73
  198. brg_certificate/tests/datapath/tx_repetition_algo_test/tx_repetition_algo_test.json +0 -17
  199. brg_certificate/tests/datapath/tx_repetition_algo_test/tx_repetition_algo_test.py +0 -118
  200. brg_certificate/tests/edge_mgmt/actions_test/actions_test.json +0 -14
  201. brg_certificate/tests/edge_mgmt/actions_test/actions_test.py +0 -396
  202. brg_certificate/tests/edge_mgmt/brg2brg_ota_ble5_test/brg2brg_ota_ble5_test.json +0 -20
  203. brg_certificate/tests/edge_mgmt/brg2brg_ota_ble5_test/brg2brg_ota_ble5_test.py +0 -94
  204. brg_certificate/tests/edge_mgmt/brg2brg_ota_test/brg2brg_ota_test.json +0 -19
  205. brg_certificate/tests/edge_mgmt/brg2brg_ota_test/brg2brg_ota_test.py +0 -87
  206. brg_certificate/tests/edge_mgmt/leds_test/leds_test.json +0 -17
  207. brg_certificate/tests/edge_mgmt/leds_test/leds_test.py +0 -223
  208. brg_certificate/tests/edge_mgmt/ota_test/ota_test.json +0 -17
  209. brg_certificate/tests/edge_mgmt/ota_test/ota_test.py +0 -128
  210. brg_certificate/tests/energy2400/output_power_test/output_power_test.json +0 -16
  211. brg_certificate/tests/energy2400/signal_indicator_ble5_10_250k_test/signal_indicator_ble5_10_250k_test.json +0 -20
  212. brg_certificate/tests/energy2400/signal_indicator_ble5_10_250k_test/signal_indicator_ble5_10_250k_test.py +0 -321
  213. brg_certificate/tests/energy2400/signal_indicator_ble5_10_500k_test/signal_indicator_ble5_10_500k_test.json +0 -20
  214. brg_certificate/tests/energy2400/signal_indicator_ble5_10_500k_test/signal_indicator_ble5_10_500k_test.py +0 -321
  215. brg_certificate/tests/energy2400/signal_indicator_sub1g_2_4_test/signal_indicator_sub1g_2_4_test.json +0 -20
  216. brg_certificate/tests/energy2400/signal_indicator_sub1g_2_4_test/signal_indicator_sub1g_2_4_test.py +0 -141
  217. brg_certificate/tests/energy2400/signal_indicator_test/signal_indicator_test.json +0 -20
  218. brg_certificate/tests/energy2400/signal_indicator_test/signal_indicator_test.py +0 -276
  219. brg_certificate/tests/energy_sub1g/signal_indicator_functionality_test/signal_indicator_functionality_test.json +0 -20
  220. brg_certificate/tests/energy_sub1g/signal_indicator_functionality_test/signal_indicator_functionality_test.py +0 -390
  221. brg_certificate/tests/energy_sub1g/signal_indicator_test/signal_indicator_test.json +0 -16
  222. brg_certificate/tests/energy_sub1g/signal_indicator_test/signal_indicator_test.py +0 -28
  223. brg_certificate/tests/sensors/ext_sensor_test/ext_sensor_test.py +0 -305
  224. brg_certificate/wltPb_pb2.pyi +0 -234
  225. brg_certificate/wlt_types.py +0 -113
  226. gw_certificate/ag/ut_defines.py +0 -364
  227. gw_certificate/ag/wlt_types.py +0 -85
  228. gw_certificate/ag/wlt_types_ag.py +0 -5310
  229. gw_certificate/ag/wlt_types_data.py +0 -64
  230. gw_certificate/api/extended_api.py +0 -23
  231. gw_certificate/api_if/200/data.json +0 -106
  232. gw_certificate/api_if/200/status.json +0 -47
  233. gw_certificate/api_if/201/data.json +0 -98
  234. gw_certificate/api_if/201/status.json +0 -53
  235. gw_certificate/api_if/205/logs.json +0 -12
  236. gw_certificate/api_if/api_validation.py +0 -38
  237. gw_certificate/api_if/gw_capabilities.py +0 -54
  238. gw_certificate/cert_results.py +0 -145
  239. gw_certificate/common/analysis_data_bricks.py +0 -60
  240. gw_certificate/common/debug.py +0 -42
  241. gw_certificate/common/serialization_formatter.py +0 -93
  242. gw_certificate/common/utils.py +0 -8
  243. gw_certificate/common/utils_defines.py +0 -15
  244. gw_certificate/common/wltPb_pb2.py +0 -84
  245. gw_certificate/gw_certificate.py +0 -154
  246. gw_certificate/gw_certificate_cli.py +0 -87
  247. gw_certificate/interface/4.4.93_app.zip +0 -0
  248. gw_certificate/interface/4.4.93_sd_bl_app.zip +0 -0
  249. gw_certificate/interface/ble_simulator.py +0 -61
  250. gw_certificate/interface/ble_sniffer.py +0 -189
  251. gw_certificate/interface/flash_fw.py +0 -90
  252. gw_certificate/interface/if_defines.py +0 -36
  253. gw_certificate/interface/mqtt.py +0 -563
  254. gw_certificate/interface/nrfutil-linux +0 -0
  255. gw_certificate/interface/nrfutil-mac +0 -0
  256. gw_certificate/interface/nrfutil.exe +0 -0
  257. gw_certificate/interface/pkt_generator.py +0 -594
  258. gw_certificate/interface/uart_if.py +0 -236
  259. gw_certificate/interface/uart_ports.py +0 -20
  260. gw_certificate/templates/results.html +0 -241
  261. gw_certificate/templates/stage.html +0 -22
  262. gw_certificate/templates/table.html +0 -6
  263. gw_certificate/templates/test.html +0 -38
  264. gw_certificate/tests/__init__.py +0 -10
  265. gw_certificate/tests/actions.py +0 -289
  266. gw_certificate/tests/bad_crc_to_PER_quantization.csv +0 -51
  267. gw_certificate/tests/connection.py +0 -188
  268. gw_certificate/tests/downlink.py +0 -172
  269. gw_certificate/tests/generic.py +0 -238
  270. gw_certificate/tests/registration.py +0 -340
  271. gw_certificate/tests/static/__init__.py +0 -0
  272. gw_certificate/tests/static/connection_defines.py +0 -9
  273. gw_certificate/tests/static/downlink_defines.py +0 -9
  274. gw_certificate/tests/static/generated_packet_table.py +0 -195
  275. gw_certificate/tests/static/packet_table.csv +0 -10067
  276. gw_certificate/tests/static/references.py +0 -5
  277. gw_certificate/tests/static/uplink_defines.py +0 -14
  278. gw_certificate/tests/throughput.py +0 -240
  279. gw_certificate/tests/uplink.py +0 -853
  280. wiliot_certificate-4.4.3.dist-info/METADATA +0 -211
  281. wiliot_certificate-4.4.3.dist-info/RECORD +0 -210
  282. wiliot_certificate-4.4.3.dist-info/entry_points.txt +0 -3
  283. wiliot_certificate-4.4.3.dist-info/top_level.txt +0 -3
  284. {brg_certificate → certificate}/__init__.py +0 -0
  285. {gw_certificate → common}/api_if/202/data.json +0 -0
  286. {gw_certificate/api_if/200 → common/api_if/202}/logs.json +0 -0
  287. {gw_certificate → common}/api_if/203/data.json +0 -0
  288. {gw_certificate/api_if/201 → common/api_if/203}/logs.json +0 -0
  289. {gw_certificate → common}/api_if/204/data.json +0 -0
  290. {gw_certificate/api_if/202 → common/api_if/204}/logs.json +0 -0
  291. {gw_certificate → common}/api_if/205/data.json +0 -0
  292. {gw_certificate/api_if/203 → common/api_if/205}/logs.json +0 -0
  293. {gw_certificate → common}/api_if/205/status.json +0 -0
  294. {gw_certificate/api_if/204 → common/api_if/206}/logs.json +0 -0
  295. {gw_certificate → common/api_if}/__init__.py +0 -0
  296. {gw_certificate/api_if → gui_certificate}/__init__.py +0 -0
  297. {wiliot_certificate-4.4.3.dist-info → wiliot_certificate-4.5.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,634 @@
1
+
2
+ import os
3
+ import random
4
+ import tabulate
5
+ import importlib # needed for importing all of the tests
6
+ from requests import codes as r_codes
7
+
8
+ # Local imports
9
+ import certificate.cert_config as cert_config
10
+ import certificate.cert_common as cert_common
11
+ import certificate.cert_results as cert_results
12
+ from certificate.wlt_types import *
13
+ from certificate.cert_defines import *
14
+ from certificate.cert_prints import *
15
+
16
+ TESTER_FW_VERSIONS = ["4.6.26", "4.6.27"]
17
+ MULTI_BRG_STR = "multi_brg" # used for multi brg tests
18
+ GW_ONLY_STR = "gw_only" # used for gw only tests
19
+ INTERNAL_BRG_STR = "internal_brg"
20
+ ORIGINAL_AG_FILE = "wlt_types_ag.py"
21
+
22
+ ##################################
23
+ # Utils
24
+ ##################################
25
+
26
+ TEST_MODULES_MAP = {"calibration": ag.MODULE_CALIBRATION, "datapath": ag.MODULE_DATAPATH, "energy2400": ag.MODULE_ENERGY_2400, "energy_sub1g": ag.MODULE_ENERGY_SUB1G,
27
+ "pwr_mgmt": ag.MODULE_PWR_MGMT, "sensors": ag.MODULE_EXT_SENSORS, "custom": ag.MODULE_CUSTOM}
28
+
29
+ def module2name(module_id):
30
+ for k, v in TEST_MODULES_MAP.items():
31
+ if module_id == v:
32
+ return k
33
+ return ''
34
+
35
+ def load_module(module_name, module_path, rel_path="."):
36
+ spec = importlib.util.spec_from_file_location(module_name, os.path.join(BASE_DIR, rel_path, module_path))
37
+ module = importlib.util.module_from_spec(spec)
38
+ spec.loader.exec_module(module)
39
+ return module
40
+
41
+ def handle_error(error, start_time):
42
+ utPrint(error, "red")
43
+ cert_results.generate_results_files(html=True, pdf=False, start_time=start_time, error=error)
44
+ sys.exit(-1)
45
+
46
+ def overwrite_defines_file(file_name, brg_id, overwrite_defs):
47
+ overwritten = {key: False for key in overwrite_defs}
48
+ with open(os.path.join(BASE_DIR, "ag", file_name), "r") as f:
49
+ lines = f.readlines()
50
+ for i, line in enumerate(lines):
51
+ for key,val in overwrite_defs.items():
52
+ pattern = r"^(\s*" + re.escape(key) + r"\s*=\s*).*$" # match the key before the "=", capture it, then replace what's after
53
+ if re.match(pattern, line):
54
+ lines[i] = re.sub(pattern, rf"\g<1>{val}", line)
55
+ overwritten[key] = True
56
+ break
57
+ for key,flag in overwritten.items():
58
+ if not flag:
59
+ utPrint(f"Couldn't overwrite '{key}' as it was not found in {file_name}!", "WARNING")
60
+ with open(os.path.join(BASE_DIR, "ag", file_name.replace('.py', f'_overwritten_for_{brg_id}.py')), "w") as f:
61
+ f.writelines(lines)
62
+ return file_name.replace('.py', f'_overwritten_for_{brg_id}.py')
63
+
64
+ def parse_cfg_file(filepath):
65
+ config = {}
66
+ with open(filepath, 'r') as f:
67
+ for line in f:
68
+ line = line.strip()
69
+ if not line or line.startswith("#"):
70
+ continue # skip empty lines and comments
71
+ if "=" in line:
72
+ key, value = line.split("=", 1)
73
+ config[key.strip()] = value.strip()
74
+ return config
75
+
76
+ ##################################
77
+ # Test
78
+ ##################################
79
+
80
+ class WltTest:
81
+ """
82
+ Wiliot Test class representing a single test case.
83
+
84
+ This class encapsulates all information needed to run a certification test,
85
+ including gateway information, bridge information, test parameters, and test results.
86
+
87
+ Attributes:
88
+ name: Test name from test list
89
+ tester: Gateway object (or string ID for backward compatibility)
90
+ dut: Device under test object (or string ID for backward compatibility)
91
+ brg1: Secondary bridge object for multi-bridge tests (optional)
92
+ active_brg: Currently active bridge being tested
93
+ test_json: Test configuration from JSON file
94
+ phases: List of test phases
95
+ params: List of test parameters
96
+ rc: Test result code (TEST_PASSED, TEST_FAILED, TEST_SKIPPED, etc.)
97
+ reason: Reason for test result
98
+ start_time: Test start time
99
+ end_time: Test end time
100
+ duration: Test duration
101
+ exit_on_param_failure: Whether to exit on parameter failure
102
+ latest: Whether to use latest version
103
+ release_candidate: Whether to use release candidate version
104
+ sterile_run: Whether to run in sterile run mode
105
+ data: Test data
106
+ rand: Random number
107
+ """
108
+ def __init__(self, line, tester, dut, brg1=None, exit_on_param_failure=False,
109
+ latest=False, release_candidate=False, sterile_run=False, data=''):
110
+ if line:
111
+ test_list_line = line.strip().split()
112
+ self.name = test_list_line[0]
113
+ self.test_module = ag.MODULE_EMPTY # Default test module
114
+ # Determine test's module
115
+ for s in self.name.split('/'):
116
+ if s in TEST_MODULES_MAP:
117
+ self.test_module = TEST_MODULES_MAP[s]
118
+ break
119
+ line_params = test_list_line[1:]
120
+ self.dir = os.path.join("tests", self.name)
121
+ self.module_name = os.path.join(os.path.basename(self.name))
122
+ self.file = os.path.join(self.dir, os.path.basename(self.name)+".py")
123
+ # Load test json
124
+ test_json_file = open(os.path.join(BASE_DIR, self.dir, os.path.basename(self.name)+".json"))
125
+ self.test_json = json.load(test_json_file)
126
+ self.gw_only = self.test_json[GW_ONLY_TEST]
127
+ self.multi_brg = self.test_json[MULTI_BRG_TEST]
128
+ self.internal_brg = INTERNAL_BRG_STR in line_params
129
+ if INTERNAL_BRG_STR in line_params: line_params.remove(INTERNAL_BRG_STR)
130
+ self.create_test_phases_and_params(line_params)
131
+ else:
132
+ self.test_json = {}
133
+ self.internal_brg = False
134
+ self.multi_brg = False
135
+ self.phases = [Phase(PRE_CONFIG), Phase(TEST_BODY), Phase(RESTORE_CONFIG)]
136
+ self.params = []
137
+
138
+ self.tester = tester
139
+ self.dut = dut
140
+ # Actual brg to cfg - can be dut, its internal_brg or None
141
+ if isinstance(self.dut, Bridge):
142
+ self.active_brg = self.dut
143
+ elif isinstance(self.dut, Gateway) and self.dut.has_internal_brg():
144
+ self.active_brg = self.dut.internal_brg
145
+ else:
146
+ self.active_brg = None
147
+ self.brg1 = brg1 if brg1 else (self.tester.internal_brg if tester and tester.internal_brg else None)
148
+ self.rc = TEST_PASSED
149
+ self.reason = ""
150
+ self.start_time = None
151
+ self.end_time = None
152
+ self.duration = None
153
+ self.exit_on_param_failure = exit_on_param_failure
154
+ self.rand = random.randrange(255)
155
+ self.latest = latest
156
+ self.release_candidate = release_candidate
157
+ self.sterile_run = sterile_run
158
+ self.data = data
159
+
160
+ def create_test_phases_and_params(self, line_params):
161
+ self.params = []
162
+ phases_source = []
163
+ dynamic_parameters = "dynamic_parameters" in self.test_json[ALL_SUPPORTED_VALUES]
164
+ if dynamic_parameters:
165
+ self.test_json[ALL_SUPPORTED_VALUES].remove("dynamic_parameters")
166
+ if len(self.test_json[ALL_SUPPORTED_VALUES]) > 0:
167
+ if dynamic_parameters:
168
+ if line_params:
169
+ phases_source = line_params
170
+ elif len(self.test_json[ALL_SUPPORTED_VALUES]) > 0:
171
+ phases_source = self.test_json[ALL_SUPPORTED_VALUES]
172
+ else:
173
+ error = f"ERROR: No dynamic parameters provided for test {self.name}! Check test list file and update the supported values!\n{[f.__dict__ for f in self.phases]}"
174
+ handle_error(error, datetime.datetime.now())
175
+ else:
176
+ phases_source = self.test_json[ALL_SUPPORTED_VALUES]
177
+ self.phases = [Phase(PRE_CONFIG)] + [Phase(phase) for phase in phases_source] + [Phase(RESTORE_CONFIG)]
178
+ for param_phase in self.phases:
179
+ param = Param(param_phase.name)
180
+ if (param.name in line_params or param.value in [eval_param(p) for p in line_params]):
181
+ self.params += [param]
182
+ else:
183
+ param_phase.tested = False
184
+ param_phase.rc = TEST_SKIPPED
185
+ if all([param_phase.rc == TEST_SKIPPED for param_phase in self.phases]):
186
+ error = f"ERROR: All params skipped for test {self.name}! Check test list file and update the supported values!\n{[f.__dict__ for f in self.phases]}"
187
+ handle_error(error, datetime.datetime.now())
188
+ else:
189
+ if line_params:
190
+ error = f"ERROR: For {self.name} params exist in test_list but not in test_json!\nline_params:{line_params}"
191
+ handle_error(error, datetime.datetime.now())
192
+ self.phases = [Phase(PRE_CONFIG), Phase(TEST_BODY), Phase(RESTORE_CONFIG)]
193
+
194
+
195
+ def get_mqttc_by_target(self, target=DUT):
196
+ if target == DUT:
197
+ return self.dut.mqttc if isinstance(self.dut, Gateway) else self.tester.mqttc
198
+ return self.tester.mqttc
199
+
200
+ # Flush all existing mqtt packets
201
+ def flush_all_mqtt_packets(self):
202
+ self.get_mqttc_by_target(TESTER).flush_pkts()
203
+ self.get_mqttc_by_target(DUT).flush_pkts()
204
+
205
+ # Phase rc
206
+ def set_phase_rc(self, phase_name, rc):
207
+ phase = self.get_phase_by_name(phase_name)
208
+ phase.rc = rc
209
+
210
+ def get_phase_rc(self, phase_name):
211
+ phase = self.get_phase_by_name(phase_name)
212
+ return phase.rc
213
+
214
+ # Phase reason
215
+ def add_phase_reason(self, phase_name, reason):
216
+ phase = self.get_phase_by_name(phase_name)
217
+ if phase.reason:
218
+ phase.reason += "\n"
219
+ if reason not in phase.reason:
220
+ phase.reason += reason
221
+
222
+ def get_phase_reason(self, phase_name):
223
+ phase = self.get_phase_by_name(phase_name)
224
+ return phase.reason
225
+
226
+ # Test funcs
227
+ def get_phase_by_name(self, phase_name):
228
+ for phase in self.phases:
229
+ if phase.name == phase_name:
230
+ return phase
231
+ return None
232
+
233
+ def add_phase(self, phase):
234
+ self.phases[-1:-1] = [phase]
235
+
236
+ def update_overall_rc(self):
237
+ if any([phase.rc == TEST_FAILED for phase in self.phases]):
238
+ self.rc = TEST_FAILED
239
+
240
+ def reset_result(self):
241
+ self.rc = TEST_PASSED
242
+ self.reason = ""
243
+
244
+ def get_seq_id(self):
245
+ self.rand = (self.rand + 1) % 256
246
+ return self.rand
247
+
248
+ # TODO - remove when test reason is re-designed
249
+ def add_reason(self, reason):
250
+ if self.reason:
251
+ self.reason += "\n"
252
+ if reason not in self.reason:
253
+ self.reason += reason
254
+
255
+ def internal_id_alias(self):
256
+ return self.dut.internal_brg.id_alias if isinstance(self.dut, Gateway) and self.dut.has_internal_brg() else self.tester.internal_brg.id_alias
257
+
258
+ def dut_is_gateway(self):
259
+ return isinstance(self.dut, Gateway)
260
+
261
+ def dut_is_bridge(self):
262
+ return isinstance(self.dut, Bridge)
263
+
264
+ def dut_is_combo(self):
265
+ return hasattr(self.dut, 'internal_brg') and self.dut.has_internal_brg()
266
+
267
+ ##################################
268
+ # Phases
269
+ ##################################
270
+ class Phase:
271
+ def __init__(self, input=None, tested=True, rc=TEST_ABORTED, reason=""):
272
+ self.name = str(input)
273
+ self.tested = tested
274
+ self.rc = rc
275
+ self.reason = reason
276
+
277
+ def __repr__(self):
278
+ return self.name
279
+
280
+ ##################################
281
+ # Param
282
+ ##################################
283
+ class Param:
284
+ def __init__(self, input=None):
285
+ self.name = str(input)
286
+ self.value = eval_param(input)
287
+
288
+ def __repr__(self):
289
+ return self.name
290
+
291
+ ##################################
292
+ # Bridge
293
+ ##################################
294
+ brg_flag = lambda validation_schema: 'modules' in validation_schema
295
+
296
+ class Bridge:
297
+ def __init__(self, id_str="", board_type=0, cfg_hash=0, api_version=ag.API_VERSION_LATEST, interface_pkt=None, import_defs=True, overwrite_defs={}, rel_path=".", validation_schema=None):
298
+ """
299
+ Initialize a Bridge object.
300
+
301
+ Args:
302
+ id_str: Bridge ID string (hex format)
303
+ board_type: Board type identifier (default: 0)
304
+ cfg_hash: Configuration hash value (default: 0)
305
+ api_version: Bridge API version (default: ag.API_VERSION_LATEST)
306
+ interface_pkt: Interface packet containing bridge information (optional)
307
+ import_defs: Whether to import and overwrite defines (default: True)
308
+ overwrite_defs: Dictionary of defines to overwrite (default: {})
309
+ rel_path: Relative path for loading modules (default: ".")
310
+ validation_schema: Validation schema dictionary
311
+ """
312
+ self.id_str = id_str
313
+ self.id_int = hex_str2int(id_str)
314
+ self.id_alias = cert_common.hex2alias_id_get(id_str)
315
+ self.board_type = interface_pkt.board_type if interface_pkt else board_type
316
+ self.version = f"{interface_pkt.major_ver}.{interface_pkt.minor_ver}.{interface_pkt.patch_ver}" if interface_pkt else ""
317
+ self.bl_version = interface_pkt.bl_version if interface_pkt else ""
318
+ self.cfg_hash = interface_pkt.cfg_hash if interface_pkt else cfg_hash
319
+ self.api_version = interface_pkt.api_version if interface_pkt else api_version
320
+ if import_defs:
321
+ if self.board_type >= len(ag.BOARD_TYPES_LIST):
322
+ handle_error(f"ERROR: Unknown board type {self.board_type} for bridge {self.id_str}!", datetime.datetime.now())
323
+ self.defines_file_name = f'{ag.BOARD_TYPES_LIST[self.board_type]}_defines.cfg'
324
+ overwrite_dict = {}
325
+ # Overwrite auto-generated defines for the specific bridge
326
+ if os.path.exists(os.path.join(BASE_DIR, "ag", self.defines_file_name)):
327
+ overwrite_dict.update(parse_cfg_file(os.path.join(BASE_DIR, "ag", self.defines_file_name)))
328
+ overwrite_dict.update(overwrite_defs) # Defines overwritten manually through cli
329
+ overwritten_defs_file = overwrite_defines_file(ORIGINAL_AG_FILE, self.id_str, overwrite_dict)
330
+ new_defines = load_module(overwritten_defs_file, f"./ag/{overwritten_defs_file}", rel_path)
331
+ ag.__dict__.update(new_defines.__dict__)
332
+ self.max_output_power_dbm = ag.BRG_DEFAULT_TX_POWER_MAX_2_4_DBM
333
+ self.validation_schema = validation_schema
334
+ self.sup_caps = []
335
+ self.modules = []
336
+ if interface_pkt:
337
+ for key, value in interface_pkt.__dict__.items():
338
+ if 'sup_cap_' in key and value:
339
+ module = key.replace('sup_cap_','')
340
+ if module in TEST_MODULES_MAP:
341
+ self.sup_caps += [TEST_MODULES_MAP[module]]
342
+ self.modules += [eval_pkt(ag.MODULES_DICT[TEST_MODULES_MAP[module]] + str(self.api_version))]
343
+ setattr(self, module, eval_pkt(ag.MODULES_DICT[TEST_MODULES_MAP[module]] + str(self.api_version)))
344
+
345
+ def update_modules(self):
346
+ self.modules = []
347
+ for sup_cap in self.sup_caps:
348
+ self.modules += [eval_pkt(ag.MODULES_DICT[sup_cap] + str(self.api_version))]
349
+
350
+ def is_sup_cap(self, test):
351
+ """Check if bridge supports the test module capability."""
352
+ return test.test_module in self.sup_caps if test.test_module and self.sup_caps else True
353
+
354
+ def __repr__(self):
355
+ version_str = f", version={self.version}" if self.version else ""
356
+ return f"Bridge(id={self.id_str}, board_type={self.board_type}{version_str})"
357
+
358
+ def cfg_brg_defaults_ret_after_fail(test):
359
+ utPrint(f"Configuring bridge {test.active_brg.id_str} to defaults", "BLUE")
360
+ modules = test.active_brg.modules
361
+ for module in modules:
362
+ utPrint(f"Configuring {module.__name__} to defaults", "BLUE")
363
+ cfg_pkt = cert_config.get_default_brg_pkt(test, module)
364
+ res = cert_config.brg_configure(test=test, cfg_pkt=cfg_pkt)[1]
365
+ if res == NO_RESPONSE:
366
+ utPrint(f"FAILURE: {module.__name__} configuration to defaults", "RED")
367
+ return NO_RESPONSE
368
+ else:
369
+ utPrint(f"SUCCESS: {module.__name__} configured to defaults", "GREEN")
370
+ return DONE
371
+
372
+ def handle_prep_brg_for_latest(test, interface, brg_id, start_time):
373
+ if test.rc == TEST_FAILED:
374
+ utPrint(f"No ModuleIf pkts found, try again", "BLUE")
375
+ test.rc = ""
376
+ test, interface = cert_common.get_module_if_pkt(test)
377
+ if test.rc == TEST_FAILED:
378
+ error = f"ERROR: No ModuleIf pkts found for 2 tries, couldn't perform OTA for bridge"
379
+ handle_error(error, start_time)
380
+ version = f"{interface.major_ver}.{interface.minor_ver}.{interface.patch_ver}"
381
+ board_type = interface.board_type
382
+ utPrint(f"BRG version [{version}], board type [{board_type}]", "BLUE")
383
+ utPrint(f"Skipping configurations for BRG {brg_id} to defaults because of latest/rc flag", "BLUE")
384
+ return Bridge(brg_id, interface_pkt=interface)
385
+
386
+ # Check BRGs are online and configure to defaults
387
+ def ut_prep_brg(args, start_time, tester, brg_id, tester_flag=False, validation_schema=None):
388
+ overwrite_defs = {} if (tester_flag or not args.overwrite_defaults) else args.overwrite_defaults
389
+ brg = Bridge(brg_id)
390
+ utPrint(SEP)
391
+ if not cert_common.is_cert_running:
392
+ versions_mgmt = load_module('versions_mgmt.py', f'{UTILS_BASE_REL_PATH}/versions_mgmt.py')
393
+ brg_owner = versions_mgmt.gw_brg_owner(env=AWS, server=PROD, brg=brg.id_str)
394
+ if brg_owner and not brg_owner in r_codes:
395
+ print_warn(f"{brg} owned by account {brg_owner}")
396
+ test = WltTest("", tester, dut=brg, exit_on_param_failure=args.exit_on_param_failure, data=args.data)
397
+ utPrint(f"Getting {brg} version and board type", "BLUE")
398
+ test, interface = cert_common.get_module_if_pkt(test)
399
+ # TODO - check validation against device response!
400
+ if args.latest or args.rc:
401
+ return handle_prep_brg_for_latest(test, interface, brg_id, start_time)
402
+ elif test.rc == TEST_FAILED:
403
+ error = f"ERROR: Didn't get ModuleIfV{test.active_brg.api_version} from BRG:{brg.id_str}!\nCheck that the brg responded with the correct module"
404
+ handle_error(error, start_time)
405
+ version = f"{interface.major_ver}.{interface.minor_ver}.{interface.patch_ver}"
406
+ board_type = interface.board_type
407
+ utPrint(f"BRG version [{version}], board type [{board_type}]", "BLUE")
408
+ test.active_brg = Bridge(brg.id_str, interface_pkt=interface, overwrite_defs=overwrite_defs, validation_schema=validation_schema)
409
+ test.dut = test.active_brg
410
+ modules_support = []
411
+ for module in TEST_MODULES_MAP:
412
+ modules_support.append([module, color("GREEN", "SUPPORTED") if TEST_MODULES_MAP[module] in test.active_brg.sup_caps else color("WARNING", "UNSUPPORTED")])
413
+ utPrint(f"BRG {brg.id_str} modules support coverage:", "BLUE")
414
+ print(tabulate.tabulate(modules_support, headers=['Module', 'Support'], tablefmt="fancy_grid"))
415
+ test.active_brg.board_type = board_type
416
+ cfg_output = cfg_brg_defaults_ret_after_fail(test=test)[1]
417
+ if cfg_output == NO_RESPONSE:
418
+ error = f"ERROR: Didn't get response from BRG:{brg.id_str}!"
419
+ handle_error(error, start_time)
420
+ test, interface = cert_common.get_module_if_pkt(test)
421
+ if test.rc == TEST_FAILED:
422
+ error = f"ERROR: Didn't get ModuleIfV{test.active_brg.api_version} from BRG:{brg.id_str}!"
423
+ handle_error(error, start_time)
424
+ utPrint(f"Received cfg hash {hex(interface.cfg_hash)}", "BLUE")
425
+ if not interface.cfg_hash or len(str(interface.cfg_hash)) < BRG_CFG_HAS_LEN:
426
+ error = f"ERROR: invalid cfg_hash for BRG:{brg.id_str}!"
427
+ handle_error(error, start_time)
428
+ utPrint(f"BRG {brg.id_str} cfg_hash_default={hex(interface.cfg_hash)}", "BLUE")
429
+ return Bridge(brg.id_str, interface_pkt=interface, overwrite_defs=overwrite_defs, validation_schema=validation_schema)
430
+
431
+ ##################################
432
+ # Gateway
433
+ ##################################
434
+ cloud_connectivity_flag = lambda validation_schema: 'properties' in validation_schema
435
+ class Gateway:
436
+ def __init__(self, id_str="", gw_version=None, gw_api_version=GW_API_VER_LATEST,
437
+ protobuf=False, mqttc=None, gw_sim=None, port='',
438
+ internal_brg=None, gw_orig_versions=None, validation_schema=None, upload_wait_time=0):
439
+ """
440
+ Initialize a Gateway object.
441
+
442
+ Args:
443
+ id_str: Gateway ID string
444
+ gw_version: Dictionary with BLE_VERSION and WIFI_VERSION keys
445
+ gw_api_version: Gateway API version
446
+ protobuf: Boolean indicating if gateway uses protobuf (default: False)
447
+ mqttc: MQTT client for the gateway
448
+ gw_sim: Gateway simulator thread (optional)
449
+ port: Port number (optional)
450
+ internal_brg: Internal Bridge object (optional)
451
+ gw_orig_versions: Original gateway versions dictionary (optional)
452
+ validation_schema: Validation schema dictionary
453
+ """
454
+ self.id_str = id_str
455
+ self.gw_version = gw_version or {}
456
+ self.gw_api_version = gw_api_version
457
+ self.mqttc = mqttc
458
+ self.gw_sim = gw_sim
459
+ self.port = port
460
+ self.internal_brg = internal_brg
461
+ self.gw_orig_versions = gw_orig_versions or gw_version or {}
462
+ self.protobuf = protobuf
463
+ self.validation_schema = validation_schema
464
+ self.upload_wait_time = upload_wait_time
465
+
466
+ def __repr__(self):
467
+ internal_brg_str = f", {self.internal_brg}" if self.internal_brg else ""
468
+ return f"Gateway(id={self.id_str}, api_version={self.gw_api_version}{internal_brg_str})"
469
+
470
+ def has_internal_brg(self):
471
+ """Check if gateway has an internal bridge."""
472
+ return self.internal_brg is not None
473
+
474
+ def is_simulated(self):
475
+ """Check if gateway is simulated."""
476
+ return self.gw_sim is not None
477
+
478
+ def get_tester_id(tester):
479
+ if not tester or tester == GW_SIM_PREFIX:
480
+ return f"GW_SIM_{get_random_hex_str(12)}"
481
+ else:
482
+ # Allow tester to be specified as tester_id:ble_addr
483
+ if ':' in tester:
484
+ tester, _ = tester.split(':')
485
+ return tester
486
+
487
+ def prep_dut(args, tester, validation_schema, mqttc, start_time, upload_wait_time):
488
+ """
489
+ Prepare device under test - returns Gateway() or Bridge() object.
490
+
491
+ Returns:
492
+ Gateway object if device is a gateway (with optional internal Bridge)
493
+ Bridge object if device is a standalone bridge
494
+ """
495
+ utPrint(SEP + f"Preparing DUT with ID {args.dut}" + SEP, "BLUE")
496
+ if cloud_connectivity_flag(validation_schema):
497
+ dut = Gateway(
498
+ id_str=args.dut,
499
+ gw_version=None,
500
+ gw_api_version=None,
501
+ protobuf=False,
502
+ mqttc=mqttc,
503
+ internal_brg=None,
504
+ gw_orig_versions=None,
505
+ validation_schema=validation_schema['properties'],
506
+ upload_wait_time=upload_wait_time
507
+ )
508
+ test = WltTest("", tester=None, dut=dut)
509
+ test, gw_info_ble_addr = prep_gw_info_action(test=test, start_time=start_time, brg_flag=brg_flag(validation_schema), target=DUT)
510
+ if brg_flag(validation_schema):
511
+ if not args.combo_ble_addr:
512
+ handle_error(f"ERROR: combo_ble_addr is missing! dut should be {args.dut}:<combo_ble_addr>", start_time)
513
+ elif gw_info_ble_addr and gw_info_ble_addr != args.combo_ble_addr:
514
+ handle_error(f"ERROR: DUT internal BRG ID from gw_info ({gw_info_ble_addr}) doesn't match the provided combo_ble_addr ({args.combo_ble_addr})!", start_time)
515
+
516
+ test.dut.gw_orig_versions = test.dut.gw_version.copy()
517
+ internal_brg_str = f":{args.combo_ble_addr}" if args.combo_ble_addr else ""
518
+ print(f"Starting certification for {test.dut}{internal_brg_str}")
519
+ # Configure GW to defaults
520
+ if not args.latest and not args.rc:
521
+ test, res = cert_config.config_gw_defaults(test, target=DUT)
522
+ if res == NO_RESPONSE:
523
+ handle_error("ERROR: Configuring gateway to defaults failed!", start_time)
524
+ # TODO - check validation against device response! (API_VALIDATION script from uplink_test)
525
+ else:
526
+ utPrint(f"Skipping configurations for gateway {test.dut.id_str} to defaults because of latest/rc flag", "BLUE")
527
+ # Prepare gateway's internal BRG
528
+ if brg_flag(validation_schema):
529
+ dut.internal_brg = ut_prep_brg(args, start_time, tester=test.dut, brg_id=args.combo_ble_addr, validation_schema=validation_schema['modules'])
530
+ if dut.internal_brg.api_version < API_OLDEST_SUPPORTED_VERSION:
531
+ handle_error(f"ERROR: DUT internal brg FW api_version={dut.internal_brg.api_version} is lower then the oldest supported = {API_OLDEST_SUPPORTED_VERSION}! Please upgrade the internal brg FW!", start_time)
532
+ # Return Gateway object
533
+ return dut
534
+
535
+ elif brg_flag(validation_schema):
536
+ # Prepare standalone bridge using prepared tester
537
+ brg = ut_prep_brg(args, start_time, tester=tester, brg_id=args.dut, validation_schema=validation_schema['modules'])
538
+ if brg.api_version < API_OLDEST_SUPPORTED_VERSION:
539
+ handle_error(f"ERROR: DUT brg FW api_version={brg.api_version} is lower then the oldest supported = {API_OLDEST_SUPPORTED_VERSION}! Please upgrade the brg FW!", start_time)
540
+ return brg
541
+
542
+
543
+ def prep_tester(args, mqttc, start_time, gw_sim_thread=None):
544
+ """
545
+ Prepare tester gateway - returns Gateway() object (can also be a simulated GW).
546
+
547
+ Returns:
548
+ Gateway object with optional internal Bridge
549
+ """
550
+ utPrint(SEP + f"Preparing tester with ID {args.tester}" + SEP, "BLUE")
551
+ tester = Gateway(
552
+ id_str=args.tester,
553
+ gw_version=None,
554
+ gw_api_version=None,
555
+ protobuf=False,
556
+ mqttc=mqttc,
557
+ gw_sim=gw_sim_thread,
558
+ port=args.port,
559
+ internal_brg=None,
560
+ gw_orig_versions=None,
561
+ validation_schema=None
562
+ )
563
+ # Prepare a GW SIM tester
564
+ if gw_sim_thread:
565
+ # Check simulator is online and configure to defaults
566
+ utPrint("Checking UART response and configure internal brg to defaults", "BLUE")
567
+ internal_brg_mac_addr = os.getenv(GW_SIM_BLE_MAC_ADDRESS)
568
+ internal_brg_ble_ver = os.getenv(GW_APP_VERSION_HEADER)
569
+ if not internal_brg_mac_addr:
570
+ handle_error(f"ERROR: Didn't receive {GW_SIM_BLE_MAC_ADDRESS} response!", start_time)
571
+ tester.gw_version = {BLE_VERSION:internal_brg_ble_ver, WIFI_VERSION:"0.0.0"}
572
+ tester.gw_api_version = GW_API_VER_LATEST
573
+
574
+ # Prepare a GW tester
575
+ else:
576
+ test = WltTest("", tester=tester, dut=None)
577
+ test, internal_brg_mac_addr = prep_gw_info_action(test=test, start_time=start_time, brg_flag=True, target=TESTER)
578
+ # Tester is expected to have ble addr in gw info response
579
+ if internal_brg_mac_addr == "":
580
+ handle_error(f"ERROR: internal_brg_mac_addr in response is empty!", start_time)
581
+ test.tester.gw_orig_versions = test.tester.gw_version.copy()
582
+ print(f"Starting certification with tester ID {test.tester.id_str} and tester's internal BRG ID {internal_brg_mac_addr}")
583
+ # Configure GW to defaults
584
+ if not args.latest and not args.rc:
585
+ test, res = cert_config.config_gw_defaults(test, target=TESTER)
586
+ if res == NO_RESPONSE:
587
+ handle_error("ERROR: Config tester to defaults failed!", start_time)
588
+ else:
589
+ utPrint(f"Skipping configurations for tester {tester} to defaults because of latest/rc flag", "BLUE")
590
+ tester = test.tester
591
+
592
+ # Prepare tester's internal BRG
593
+ tester.internal_brg = ut_prep_brg(args, start_time, tester, internal_brg_mac_addr, tester_flag=True, validation_schema=None)
594
+ # Return Gateway object
595
+ return tester
596
+
597
+ def prep_gw_info_action(test, start_time, brg_flag, target):
598
+ # TODO - make sure certification can run with new assumptions (results, bitbucket-pipelines, etc.)
599
+ gw = test.dut if target == DUT else test.tester
600
+ utPrint(f"Getting {gw} information", "BLUE")
601
+ response = cert_common.get_gw_info(test, target=target)
602
+ if response == NO_RESPONSE:
603
+ error = f"ERROR: Didn't get response from {gw} !"
604
+ handle_error(error, start_time)
605
+ internal_brg_mac_addr = ""
606
+ if ENTRIES in response[GW_INFO]:
607
+ # Protobuf
608
+ info = response[GW_INFO][ENTRIES]
609
+ gw.protobuf = True
610
+ if BLE_VERSION in info and WIFI_VERSION in info:
611
+ gw.gw_version = {BLE_VERSION : info[BLE_VERSION][STR_VAL], WIFI_VERSION : info[WIFI_VERSION][STR_VAL]}
612
+ if brg_flag and BLE_MAC_ADDR in info:
613
+ internal_brg_mac_addr = info[BLE_MAC_ADDR][STR_VAL]
614
+ if GW_API_VERSION in info:
615
+ gw.gw_api_version = info[GW_API_VERSION][STR_VAL]
616
+ else:
617
+ # JSON
618
+ info = response[GW_INFO]
619
+ gw.protobuf = False
620
+ if BLE_VERSION in info and WIFI_VERSION in info:
621
+ gw.gw_version = {BLE_VERSION : info[BLE_VERSION], WIFI_VERSION : info[WIFI_VERSION]}
622
+ if brg_flag and BLE_MAC_ADDR in info:
623
+ internal_brg_mac_addr = info[BLE_MAC_ADDR]
624
+ # For internal use only in versions update test
625
+ if GW_API_VERSION in info:
626
+ gw.gw_api_version = info[GW_API_VERSION]
627
+
628
+ if target == DUT:
629
+ test.dut = gw
630
+ else:
631
+ test.tester = gw
632
+
633
+ return test, internal_brg_mac_addr
634
+