wiliot-certificate 1.3.0a1__py3-none-any.whl → 1.4.0a2__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 (184) hide show
  1. brg_certificate/__init__.py +0 -0
  2. brg_certificate/ag/energous_v0_defines.py +925 -0
  3. brg_certificate/ag/energous_v1_defines.py +931 -0
  4. brg_certificate/ag/energous_v2_defines.py +925 -0
  5. brg_certificate/ag/energous_v3_defines.py +925 -0
  6. brg_certificate/ag/energous_v4_defines.py +925 -0
  7. brg_certificate/ag/fanstel_lan_v0_defines.py +925 -0
  8. brg_certificate/ag/fanstel_lte_v0_defines.py +925 -0
  9. brg_certificate/ag/fanstel_wifi_v0_defines.py +925 -0
  10. brg_certificate/ag/minew_lte_v0_defines.py +925 -0
  11. brg_certificate/ag/wlt_cmd_if.html +102 -0
  12. brg_certificate/ag/wlt_types.html +6114 -0
  13. brg_certificate/ag/wlt_types_ag.py +7840 -0
  14. brg_certificate/ag/wlt_types_ag_jsons/brg2brg_ota.json +142 -0
  15. brg_certificate/ag/wlt_types_ag_jsons/brg2gw_hb.json +785 -0
  16. brg_certificate/ag/wlt_types_ag_jsons/brg2gw_hb_sleep.json +139 -0
  17. brg_certificate/ag/wlt_types_ag_jsons/calibration.json +394 -0
  18. brg_certificate/ag/wlt_types_ag_jsons/custom.json +515 -0
  19. brg_certificate/ag/wlt_types_ag_jsons/datapath.json +672 -0
  20. brg_certificate/ag/wlt_types_ag_jsons/energy2400.json +550 -0
  21. brg_certificate/ag/wlt_types_ag_jsons/energySub1g.json +595 -0
  22. brg_certificate/ag/wlt_types_ag_jsons/externalSensor.json +598 -0
  23. brg_certificate/ag/wlt_types_ag_jsons/interface.json +938 -0
  24. brg_certificate/ag/wlt_types_ag_jsons/powerManagement.json +1234 -0
  25. brg_certificate/ag/wlt_types_ag_jsons/side_info_sensor.json +105 -0
  26. brg_certificate/ag/wlt_types_ag_jsons/signal_indicator_data.json +77 -0
  27. brg_certificate/ag/wlt_types_ag_jsons/unified_echo_ext_pkt.json +61 -0
  28. brg_certificate/ag/wlt_types_ag_jsons/unified_echo_pkt.json +110 -0
  29. brg_certificate/brg_certificate.py +191 -0
  30. brg_certificate/brg_certificate_cli.py +47 -0
  31. brg_certificate/cert_common.py +828 -0
  32. brg_certificate/cert_config.py +395 -0
  33. brg_certificate/cert_data_sim.py +188 -0
  34. brg_certificate/cert_defines.py +337 -0
  35. brg_certificate/cert_gw_sim.py +285 -0
  36. brg_certificate/cert_mqtt.py +373 -0
  37. brg_certificate/cert_prints.py +181 -0
  38. brg_certificate/cert_protobuf.py +88 -0
  39. brg_certificate/cert_results.py +300 -0
  40. brg_certificate/cert_utils.py +358 -0
  41. brg_certificate/certificate_sanity_test_list.txt +36 -0
  42. brg_certificate/certificate_test_list.txt +43 -0
  43. brg_certificate/config/eclipse.json +10 -0
  44. brg_certificate/config/hivemq.json +10 -0
  45. brg_certificate/config/mosquitto.json +10 -0
  46. brg_certificate/config/mosquitto.md +95 -0
  47. brg_certificate/config/wiliot-dev.json +10 -0
  48. brg_certificate/restore_brg.py +59 -0
  49. brg_certificate/tests/calibration/interval_test/interval_test.json +13 -0
  50. brg_certificate/tests/calibration/interval_test/interval_test.py +28 -0
  51. brg_certificate/tests/calibration/output_power_test/output_power_test.json +13 -0
  52. brg_certificate/tests/calibration/output_power_test/output_power_test.py +28 -0
  53. brg_certificate/tests/calibration/pattern_test/pattern_test.json +13 -0
  54. brg_certificate/tests/calibration/pattern_test/pattern_test.py +70 -0
  55. brg_certificate/tests/datapath/adaptive_pacer_algo_test/adaptive_pacer_algo_test.json +13 -0
  56. brg_certificate/tests/datapath/adaptive_pacer_algo_test/adaptive_pacer_algo_test.py +76 -0
  57. brg_certificate/tests/datapath/num_of_tags_test/num_of_tags_test.json +13 -0
  58. brg_certificate/tests/datapath/num_of_tags_test/num_of_tags_test.py +83 -0
  59. brg_certificate/tests/datapath/output_power_test/output_power_test.json +13 -0
  60. brg_certificate/tests/datapath/output_power_test/output_power_test.py +27 -0
  61. brg_certificate/tests/datapath/pacer_interval_ble5_test/pacer_interval_ble5_test.json +13 -0
  62. brg_certificate/tests/datapath/pacer_interval_ble5_test/pacer_interval_ble5_test.py +43 -0
  63. brg_certificate/tests/datapath/pacer_interval_tags_count_test/pacer_interval_tags_count_test.json +13 -0
  64. brg_certificate/tests/datapath/pacer_interval_tags_count_test/pacer_interval_tags_count_test.py +63 -0
  65. brg_certificate/tests/datapath/pacer_interval_test/pacer_interval_test.json +13 -0
  66. brg_certificate/tests/datapath/pacer_interval_test/pacer_interval_test.py +50 -0
  67. brg_certificate/tests/datapath/pattern_test/pattern_test.json +13 -0
  68. brg_certificate/tests/datapath/pattern_test/pattern_test.py +28 -0
  69. brg_certificate/tests/datapath/pkt_filter_ble5_test/pkt_filter_ble5_test.json +13 -0
  70. brg_certificate/tests/datapath/pkt_filter_ble5_test/pkt_filter_ble5_test.py +51 -0
  71. brg_certificate/tests/datapath/pkt_filter_gen3_test/pkt_filter_gen3_test.json +13 -0
  72. brg_certificate/tests/datapath/pkt_filter_gen3_test/pkt_filter_gen3_test.py +54 -0
  73. brg_certificate/tests/datapath/pkt_filter_test/pkt_filter_test.json +13 -0
  74. brg_certificate/tests/datapath/pkt_filter_test/pkt_filter_test.py +55 -0
  75. brg_certificate/tests/datapath/rssi_threshold_test/rssi_threshold_test.json +13 -0
  76. brg_certificate/tests/datapath/rssi_threshold_test/rssi_threshold_test.py +73 -0
  77. brg_certificate/tests/datapath/rx_channel_test/rx_channel_test.json +13 -0
  78. brg_certificate/tests/datapath/rx_channel_test/rx_channel_test.py +41 -0
  79. brg_certificate/tests/datapath/rx_rate_gen2_test/rx_rate_gen2_test.json +21 -0
  80. brg_certificate/tests/datapath/rx_rate_gen2_test/rx_rate_gen2_test.py +184 -0
  81. brg_certificate/tests/datapath/rx_rate_gen3_test/rx_rate_gen3_test.json +21 -0
  82. brg_certificate/tests/datapath/rx_rate_gen3_test/rx_rate_gen3_test.py +210 -0
  83. brg_certificate/tests/datapath/stress_gen3_test/stress_gen3_test.json +30 -0
  84. brg_certificate/tests/datapath/stress_gen3_test/stress_gen3_test.py +203 -0
  85. brg_certificate/tests/datapath/stress_test/stress_test.json +30 -0
  86. brg_certificate/tests/datapath/stress_test/stress_test.py +210 -0
  87. brg_certificate/tests/datapath/tx_repetition_algo_test/tx_repetition_algo_test.json +13 -0
  88. brg_certificate/tests/datapath/tx_repetition_algo_test/tx_repetition_algo_test.py +113 -0
  89. brg_certificate/tests/datapath/tx_repetition_test/tx_repetition_test.json +13 -0
  90. brg_certificate/tests/datapath/tx_repetition_test/tx_repetition_test.py +79 -0
  91. brg_certificate/tests/edge_mgmt/actions_test/actions_test.json +13 -0
  92. brg_certificate/tests/edge_mgmt/actions_test/actions_test.py +432 -0
  93. brg_certificate/tests/edge_mgmt/brg2brg_ota_ble5_test/brg2brg_ota_ble5_test.json +13 -0
  94. brg_certificate/tests/edge_mgmt/brg2brg_ota_ble5_test/brg2brg_ota_ble5_test.py +94 -0
  95. brg_certificate/tests/edge_mgmt/brg2brg_ota_test/brg2brg_ota_test.json +13 -0
  96. brg_certificate/tests/edge_mgmt/brg2brg_ota_test/brg2brg_ota_test.py +87 -0
  97. brg_certificate/tests/edge_mgmt/leds_test/leds_test.json +13 -0
  98. brg_certificate/tests/edge_mgmt/leds_test/leds_test.py +210 -0
  99. brg_certificate/tests/edge_mgmt/ota_test/ota_test.json +13 -0
  100. brg_certificate/tests/edge_mgmt/ota_test/ota_test.py +83 -0
  101. brg_certificate/tests/edge_mgmt/stat_test/stat_test.json +13 -0
  102. brg_certificate/tests/edge_mgmt/stat_test/stat_test.py +48 -0
  103. brg_certificate/tests/energy2400/duty_cycle_test/duty_cycle_test.json +13 -0
  104. brg_certificate/tests/energy2400/duty_cycle_test/duty_cycle_test.py +26 -0
  105. brg_certificate/tests/energy2400/output_power_test/output_power_test.json +13 -0
  106. brg_certificate/tests/energy2400/output_power_test/output_power_test.py +27 -0
  107. brg_certificate/tests/energy2400/pattern_test/pattern_test.json +13 -0
  108. brg_certificate/tests/energy2400/pattern_test/pattern_test.py +28 -0
  109. brg_certificate/tests/energy2400/signal_indicator_ble5_test/signal_indicator_ble5_test.json +13 -0
  110. brg_certificate/tests/energy2400/signal_indicator_ble5_test/signal_indicator_ble5_test.py +398 -0
  111. brg_certificate/tests/energy2400/signal_indicator_sub1g_2_4_test/signal_indicator_sub1g_2_4_test.json +13 -0
  112. brg_certificate/tests/energy2400/signal_indicator_sub1g_2_4_test/signal_indicator_sub1g_2_4_test.py +153 -0
  113. brg_certificate/tests/energy2400/signal_indicator_test/signal_indicator_test.json +13 -0
  114. brg_certificate/tests/energy2400/signal_indicator_test/signal_indicator_test.py +264 -0
  115. brg_certificate/tests/energy_sub1g/duty_cycle_test/duty_cycle_test.json +13 -0
  116. brg_certificate/tests/energy_sub1g/duty_cycle_test/duty_cycle_test.py +27 -0
  117. brg_certificate/tests/energy_sub1g/pattern_test/pattern_test.json +13 -0
  118. brg_certificate/tests/energy_sub1g/pattern_test/pattern_test.py +26 -0
  119. brg_certificate/tests/energy_sub1g/signal_indicator_functionality_test/signal_indicator_functionality_test.json +13 -0
  120. brg_certificate/tests/energy_sub1g/signal_indicator_functionality_test/signal_indicator_functionality_test.py +397 -0
  121. brg_certificate/tests/energy_sub1g/signal_indicator_test/signal_indicator_test.json +13 -0
  122. brg_certificate/tests/energy_sub1g/signal_indicator_test/signal_indicator_test.py +27 -0
  123. brg_certificate/wltPb_pb2.py +72 -0
  124. brg_certificate/wltPb_pb2.pyi +227 -0
  125. brg_certificate/wlt_types.py +114 -0
  126. gw_certificate/api/extended_api.py +7 -1531
  127. gw_certificate/api_if/200/data.json +106 -0
  128. gw_certificate/api_if/200/logs.json +12 -0
  129. gw_certificate/api_if/200/status.json +47 -0
  130. gw_certificate/api_if/201/data.json +98 -0
  131. gw_certificate/api_if/201/logs.json +12 -0
  132. gw_certificate/api_if/201/status.json +53 -0
  133. gw_certificate/api_if/202/data.json +83 -0
  134. gw_certificate/api_if/202/logs.json +12 -0
  135. gw_certificate/api_if/202/status.json +60 -0
  136. gw_certificate/api_if/203/data.json +85 -0
  137. gw_certificate/api_if/203/logs.json +12 -0
  138. gw_certificate/api_if/203/status.json +63 -0
  139. gw_certificate/api_if/204/data.json +85 -0
  140. gw_certificate/api_if/204/logs.json +12 -0
  141. gw_certificate/api_if/204/status.json +63 -0
  142. gw_certificate/api_if/205/data.json +85 -0
  143. gw_certificate/api_if/205/logs.json +12 -0
  144. gw_certificate/api_if/205/status.json +63 -0
  145. gw_certificate/api_if/api_validation.py +0 -2
  146. gw_certificate/common/analysis_data_bricks.py +18 -1413
  147. gw_certificate/common/debug.py +0 -21
  148. gw_certificate/common/utils.py +1 -212
  149. gw_certificate/common/utils_defines.py +0 -87
  150. gw_certificate/gw_certificate.py +9 -7
  151. gw_certificate/gw_certificate_cli.py +39 -23
  152. gw_certificate/interface/4.4.52_app.zip +0 -0
  153. gw_certificate/interface/4.4.52_sd_bl_app.zip +0 -0
  154. gw_certificate/interface/ble_simulator.py +0 -32
  155. gw_certificate/interface/if_defines.py +1 -0
  156. gw_certificate/interface/mqtt.py +96 -19
  157. gw_certificate/interface/nrfutil-linux +0 -0
  158. gw_certificate/interface/nrfutil-mac +0 -0
  159. gw_certificate/interface/nrfutil.exe +0 -0
  160. gw_certificate/interface/pkt_generator.py +0 -82
  161. gw_certificate/interface/uart_if.py +73 -43
  162. gw_certificate/templates/results.html +1 -1
  163. gw_certificate/tests/__init__.py +1 -2
  164. gw_certificate/tests/actions.py +134 -9
  165. gw_certificate/tests/connection.py +10 -5
  166. gw_certificate/tests/downlink.py +2 -4
  167. gw_certificate/tests/generic.py +62 -12
  168. gw_certificate/tests/registration.py +78 -27
  169. gw_certificate/tests/static/generated_packet_table.py +12 -48
  170. gw_certificate/tests/static/packet_table.csv +10048 -10048
  171. gw_certificate/tests/static/references.py +2 -1
  172. gw_certificate/tests/static/uplink_defines.py +0 -7
  173. gw_certificate/tests/throughput.py +7 -12
  174. gw_certificate/tests/uplink.py +83 -43
  175. {wiliot_certificate-1.3.0a1.dist-info → wiliot_certificate-1.4.0a2.dist-info}/METADATA +59 -8
  176. wiliot_certificate-1.4.0a2.dist-info/RECORD +198 -0
  177. {wiliot_certificate-1.3.0a1.dist-info → wiliot_certificate-1.4.0a2.dist-info}/WHEEL +1 -1
  178. wiliot_certificate-1.4.0a2.dist-info/entry_points.txt +3 -0
  179. wiliot_certificate-1.4.0a2.dist-info/top_level.txt +2 -0
  180. gw_certificate/interface/packet_error.py +0 -22
  181. wiliot_certificate-1.3.0a1.dist-info/RECORD +0 -51
  182. wiliot_certificate-1.3.0a1.dist-info/entry_points.txt +0 -2
  183. wiliot_certificate-1.3.0a1.dist-info/top_level.txt +0 -1
  184. {wiliot_certificate-1.3.0a1.dist-info → wiliot_certificate-1.4.0a2.dist-info}/LICENSE +0 -0
@@ -0,0 +1,398 @@
1
+ from brg_certificate.cert_prints import *
2
+ from brg_certificate.cert_defines import *
3
+ from brg_certificate.wlt_types import *
4
+ import brg_certificate.cert_common as cert_common
5
+ import brg_certificate.cert_config as cert_config
6
+ import random
7
+
8
+ # Test Description:
9
+ # This test is to verify the functionality of both signal indicator tx (tx_brg) and rx (rx_brg) at BRG level.
10
+ # We will configure several signal indicator params during the test, and check the functionality of the signal indicator logic
11
+ # for each of them.
12
+ # It is important to execute the test with several setups: 2 Fanstel BRG's, 2 Minew BRG's and 1 Fanstel and 1 Minew BRG.
13
+ # At first, we will configure several tx signal indicator params and check for ack's, to verify all indicated params were
14
+ # received at the cloud.
15
+ # Then, we will examine the signal indicator end-2-end logic with both transmitter and receiver:
16
+ # phase 1 - One BRG will be configured as signal indicator tx, and the other as signal indicator rx, and we expect to see
17
+ # signal indicator packets only from the tx BRG, and according to the tx params (to check the repetition and cycle params).
18
+ # phase 2 - Same as phase 1, but with different tx params configured.
19
+ # phase 3 - One rx BRG without any tx BRG. We don't expect to see any signal indicator packets. This phase is to verify the
20
+ # brg module logic is working properly, and no tag packet is accidentally being treated as signal indicator packet.
21
+ # phase 4 - Both BRG's will be configured to be transmitters and receivers, with different tx params for each one. we expect
22
+ # to see signal indicator packets from both BRG's, according to the tx params.
23
+ # phase 5 - One BRG will be configured as signal indicator tx, but no rx, so we don't expect to receive signal indicatopr packets.
24
+ # that way we can assure the logic within the receiver is not confused by the signal indicator uuid as external sensor.
25
+
26
+ # Test MACROS #
27
+ DEFAULT_HDR = ag.Hdr(group_id=ag.GROUP_ID_GW2BRG)
28
+ NUM_OF_SCANNING_CYCLE = 2
29
+ DEFAULT_SCAN_TIME = 60
30
+ SCAN_DELAY_TIME = 5
31
+ BOARD_TYPES_2_POLARIZATION_ANT_LIST = [ag.BOARD_TYPE_MINEW_SINGLE_BAND_V0, ag.BOARD_TYPE_MINEW_DUAL_BAND_V0, ag.BOARD_TYPE_ENERGOUS_V2, ag.BOARD_TYPE_ERM_V0, ag.BOARD_TYPE_ERM_V1]
32
+ VALUES_DICT = {0:(15,3),1:(30,3),2:(60,4),3:(ag.BRG_DEFAULT_SIGNAL_INDICATOR_CYCLE, ag.BRG_DEFAULT_SIGNAL_INDICATOR_REP),4:[(15,3),(15,4)],5:(15,1)}
33
+ CYCLE_IDX = 0
34
+ REP_IDX = 1
35
+ TX_BRG_IDX = 0
36
+ RX_BRG_IDX = 1
37
+ BLE4_LISTEN_PERIOD = 15
38
+ BLE4_BROADCAST_DURATION = BLE4_LISTEN_PERIOD + 1
39
+
40
+ # Helper function #
41
+ def get_phase_tx_params_values(phase, brg):
42
+ if phase == 4:
43
+ return VALUES_DICT[phase][brg][CYCLE_IDX] , VALUES_DICT[phase][brg][REP_IDX]
44
+ else:
45
+ return VALUES_DICT[phase][CYCLE_IDX], VALUES_DICT[phase][REP_IDX]
46
+
47
+ # Test functions #
48
+ def mqtt_scan_n_create_log_file(test, duration, phase, value):
49
+ test.mqttc.flush_pkts()
50
+ mqtt_scan_wait(test, duration=duration)
51
+ generate_log_file(test, f"{phase}_{value}")
52
+
53
+ def get_all_signal_ind_pkt(test=None, rx_brg=None, tx_brg=None):
54
+ if rx_brg == test.brg1:
55
+ all_sensor_packets = cert_mqtt.get_all_brg1_ext_sensor_pkts(mqttc=test.mqttc, test=test)
56
+ elif rx_brg == test.brg0:
57
+ all_sensor_packets = cert_mqtt.get_all_sensor_pkts(mqttc=test.mqttc, test=test)
58
+ signal_ind_pkts = []
59
+ for p in all_sensor_packets:
60
+ if p[SENSOR_UUID] == "{:06X}".format(ag.SENSOR_SERVICE_ID_SIGNAL_INDICATOR) and p[BRIDGE_ID] == rx_brg.id_str and (p[SENSOR_ID] == tx_brg.id_alias or hex_str2int(p[SENSOR_ID]) == tx_brg.id_str):
61
+ signal_ind_pkts.append(p)
62
+ return signal_ind_pkts
63
+
64
+ def expected_signal_ind_pkts_calc(tx_brg, rx_brg):
65
+ if (tx_brg.board_type in BOARD_TYPES_2_POLARIZATION_ANT_LIST):
66
+ tx_brg_ant_polarization_num = 2
67
+ else:
68
+ tx_brg_ant_polarization_num = 1
69
+ if (rx_brg.board_type in BOARD_TYPES_2_POLARIZATION_ANT_LIST):
70
+ rx_brg_ant_polarization_num = 2
71
+ else:
72
+ rx_brg_ant_polarization_num = 1
73
+ return NUM_OF_SCANNING_CYCLE * tx_brg_ant_polarization_num * rx_brg_ant_polarization_num
74
+
75
+ def terminate_test(test, phase=0, revert_rx_brg=False, revert_tx_brg=False, modules=[]):
76
+ # Temp solution for internal_brg test because test_epilog doesn't support both internal brg and test.brgs
77
+ utPrint(f"Terminating test (phase={phase})!!!!!!!!\n", "BLUE")
78
+ if revert_rx_brg:
79
+ restore_modules = [modules[1]] if (test.internal_brg or phase != 4) else modules
80
+ restore_modules.append(eval_pkt(f'ModuleDatapathV{test.active_brg.api_version}'))
81
+ utPrint(f"reverting rx_brg {test.brg1.id_str} to defaults\n", "BOLD")
82
+ test, response = cert_config.config_brg1_defaults(test, modules=restore_modules, ble5=True)
83
+ if response == NO_RESPONSE and test.exit_on_param_failure:
84
+ test.rc = TEST_FAILED
85
+ test.add_reason(f"BRG {test.brg1.id_str} didn't revert modules "
86
+ f"{restore_modules} to default configuration!")
87
+
88
+ if revert_tx_brg:
89
+ restore_modules = [modules[0]] if (test.internal_brg or phase != 4) else modules
90
+ restore_modules.append(eval_pkt(f'ModuleDatapathV{test.active_brg.api_version}'))
91
+ utPrint(f"reverting tx_brg {test.brg0.id_str} to defaults\n", "BOLD")
92
+ test, response = cert_config.config_brg_defaults(test, modules=restore_modules, ble5=True)
93
+ if response == NO_RESPONSE and test.exit_on_param_failure:
94
+ test.rc = TEST_FAILED
95
+ test.add_reason(f"BRG {test.brg0.id_str} didn't revert modules"
96
+ f"{restore_modules} to default configuration!")
97
+ return cert_common.test_epilog(test)
98
+
99
+ # Test execution #
100
+ def run(test):
101
+
102
+ # Test modules evaluation #
103
+ energy2400_module = eval_pkt(f'ModuleEnergy2400V{test.active_brg.api_version}')
104
+ ext_sensors_module = eval_pkt(f'ModuleExtSensorsV{test.active_brg.api_version}')
105
+ datapath_module = eval_pkt(f'ModuleDatapathV{test.active_brg.api_version}')
106
+
107
+ # Transmitter related defines #
108
+ tx_brg_ = test.brg0
109
+ tx_module = energy2400_module
110
+
111
+ # Receiver related defines #
112
+ rx_brg_ = test.brg1
113
+
114
+ # RSSI Threshold
115
+ rssi_threshold = -25
116
+
117
+ # Modules list #
118
+ modules = [tx_module, ext_sensors_module]
119
+
120
+ # Test prolog
121
+ test = cert_common.test_prolog(test)
122
+ if test.rc == TEST_FAILED or test.reason != TEST_SUCCESS:
123
+ return terminate_test(test)
124
+
125
+ for param in test.params:
126
+ test = cert_config.brg_configure(test, fields=[BRG_RX_CHANNEL], values=[param.value], module=datapath_module)[0]
127
+ test = cert_config.brg1_configure(test, fields=[BRG_RX_CHANNEL], values=[param.value], module=datapath_module)[0]
128
+ if test.rc == TEST_FAILED and test.exit_on_param_failure:
129
+ return terminate_test(test, phase=1, revert_rx_brg=True,revert_tx_brg=True, modules=modules)
130
+
131
+ phase = 0
132
+ tx_signal_ind_cycle, tx_signal_ind_rep = get_phase_tx_params_values(phase, TX_BRG_IDX)
133
+ utPrint(f"TX BRG with RX- cycle = {tx_signal_ind_cycle}, repetition = {tx_signal_ind_rep}\n", "BLUE")
134
+ # configuring receiver #
135
+ utPrint(f"Configuring BRG {rx_brg_.id_str} as Signal Indicator Receiver with RSSI Threshold of {rssi_threshold}", "BOLD")
136
+ test = cert_config.brg1_configure(test=test, module=ext_sensors_module, fields=[BRG_SENSOR0, BRG_RSSI_THRESHOLD], values=[ag.EXTERNAL_SENSORS_SIGNAL_INDICATOR, rssi_threshold], ble5=True)[0]
137
+ if test.rc == TEST_FAILED and test.exit_on_param_failure:
138
+ test.add_reason(f"BRG {rx_brg_.id_str}: didn't receive signal indicator receiver configuration!")
139
+ return terminate_test(test, phase=phase, revert_rx_brg=True, revert_tx_brg=True, modules=modules)
140
+ # configuring transmitter #
141
+ utPrint(f"Configuring BRG {tx_brg_.id_str} as Signal Indicator Transmitter", "BOLD")
142
+ transmitter_cfg_pkt = WltPkt(hdr=DEFAULT_HDR, pkt=tx_module(seq_id=random.randrange(99), brg_mac=tx_brg_.id_int,
143
+ signal_indicator_cycle=tx_signal_ind_cycle, signal_indicator_rep=tx_signal_ind_rep))
144
+ cert_config.brg_configure_ble5(test=test, cfg_pkt=transmitter_cfg_pkt, wait=False)
145
+ if test.rc == TEST_FAILED:
146
+ test.add_reason(f"BRG {tx_brg_.id_str}: didn't receive signal indicator transmitter configuration!")
147
+ return test
148
+ utPrint(f"BRG {tx_brg_.id_str} configured to be transmitter - cycle = {tx_signal_ind_cycle},"
149
+ f"repetition = {tx_signal_ind_rep}", "BOLD")
150
+ # phase analysis #
151
+ mqtt_scan_n_create_log_file(test, (NUM_OF_SCANNING_CYCLE * tx_signal_ind_cycle) + SCAN_DELAY_TIME, phase, f"rssi_threshold")
152
+ received_signal_ind_pkts = get_all_signal_ind_pkt(test=test, rx_brg=rx_brg_, tx_brg=tx_brg_)
153
+ rssi_threshold_viloation_pkts = [p for p in received_signal_ind_pkts if p[RSSI] >= -1*rssi_threshold]
154
+ if rssi_threshold_viloation_pkts:
155
+ test.rc = TEST_FAILED
156
+ test.add_reason(f"rssi_threshold phase failed - BRG {rx_brg_.id_str} echoed" +
157
+ f" {len(rssi_threshold_viloation_pkts)} signal indicator packets\n with RSSI weaker than {rssi_threshold}")
158
+ field_functionality_pass_fail_print(test, 'phase', phase)
159
+ if test.rc == TEST_FAILED:
160
+ return terminate_test(test, phase=phase, revert_rx_brg=True,revert_tx_brg=True, modules=modules)
161
+
162
+ phase = 1
163
+ functionality_run_print(f"phase {phase}")
164
+ # Phase 1 - Tx BRG with rx. expecting the receiver to receive signal indicator packets from the transmitter
165
+ # according to the tx params.
166
+ tx_signal_ind_cycle, tx_signal_ind_rep = get_phase_tx_params_values(phase, TX_BRG_IDX)
167
+ utPrint(f"TX BRG with RX- cycle = {tx_signal_ind_cycle}, repetition = {tx_signal_ind_rep}\n", "BLUE")
168
+ # configuring receiver #
169
+ utPrint(f"Configuring BRG {rx_brg_.id_str} as Signal Indicator Receiver", "BOLD")
170
+ test = cert_config.brg1_configure(test=test, module=ext_sensors_module, fields=[BRG_SENSOR0], values=[ag.EXTERNAL_SENSORS_SIGNAL_INDICATOR], ble5=True)[0]
171
+ if test.rc == TEST_FAILED and test.exit_on_param_failure:
172
+ test.add_reason(f"BRG {rx_brg_.id_str}: didn't receive signal indicator receiver configuration!")
173
+ return terminate_test(test, phase=phase, revert_rx_brg=True, revert_tx_brg=True, modules=modules)
174
+ # configuring transmitter #
175
+ utPrint(f"Configuring BRG {tx_brg_.id_str} as Signal Indicator Transmitter", "BOLD")
176
+ transmitter_cfg_pkt = WltPkt(hdr=DEFAULT_HDR, pkt=tx_module(seq_id=random.randrange(99), brg_mac=tx_brg_.id_int,
177
+ signal_indicator_cycle=tx_signal_ind_cycle, signal_indicator_rep=tx_signal_ind_rep))
178
+ cert_config.brg_configure_ble5(test=test, cfg_pkt=transmitter_cfg_pkt, wait=False)
179
+ utPrint(f"BRG {tx_brg_.id_str} configured to be transmitter - cycle = {tx_signal_ind_cycle},"
180
+ f"repetition = {tx_signal_ind_rep}", "BOLD")
181
+ print_update_wait(BLE4_BROADCAST_DURATION) # BLE5 configuration can take up to BLE4_BROADCAST_DURATION sec
182
+ # phase analysis
183
+ mqtt_scan_n_create_log_file(test, (NUM_OF_SCANNING_CYCLE * tx_signal_ind_cycle) + SCAN_DELAY_TIME, phase, value=param.name)
184
+ expected_signal_ind_pkts = expected_signal_ind_pkts_calc(tx_brg_, rx_brg_)
185
+ received_signal_ind_pkts = get_all_signal_ind_pkt(test=test, rx_brg=rx_brg_, tx_brg=tx_brg_)
186
+ txt = f"""Phase {phase} - BRG {rx_brg_.id_str} signal indicator packets:
187
+ received {len(received_signal_ind_pkts)} packets, expected {expected_signal_ind_pkts} packets"""
188
+ print(txt)
189
+ if (not len(received_signal_ind_pkts) or
190
+ len(received_signal_ind_pkts) < expected_signal_ind_pkts or
191
+ len(received_signal_ind_pkts) > expected_signal_ind_pkts):
192
+ test.rc = TEST_FAILED
193
+ test.add_reason(txt)
194
+ test.set_phase_rc(param.name, test.rc)
195
+ test.add_phase_reason(param.name, test.reason)
196
+ field_functionality_pass_fail_print(test, 'phase', phase)
197
+ if test.rc == TEST_FAILED:
198
+ return terminate_test(test, phase=phase, revert_rx_brg=True,revert_tx_brg=True, modules=modules)
199
+
200
+ phase = 2
201
+ functionality_run_print(f"phase {phase}")
202
+ # Phase 2 - Tx BRG with rx. tx params changed from last values configured in phase 1
203
+ # expecting the receiver to receive signal indicator packets from the transmitter according to the tx params.
204
+ tx_signal_ind_cycle, tx_signal_ind_rep = get_phase_tx_params_values(phase, TX_BRG_IDX)
205
+ utPrint(f"TX BRG with RX- cycle = {tx_signal_ind_cycle}, repetition = {tx_signal_ind_rep}\n", "BLUE")
206
+ # configuring transmitter #
207
+ utPrint(f"Configuring BRG {tx_brg_.id_str} as Signal Indicator Transmitter", "BOLD")
208
+ transmitter_cfg_pkt = WltPkt(hdr=DEFAULT_HDR, pkt=tx_module(seq_id=random.randrange(99), brg_mac=tx_brg_.id_int,
209
+ signal_indicator_cycle=tx_signal_ind_cycle, signal_indicator_rep=tx_signal_ind_rep))
210
+ cert_config.brg_configure_ble5(test=test, cfg_pkt=transmitter_cfg_pkt, wait=False)
211
+ utPrint(f"BRG {tx_brg_.id_str} configured to be transmitter - cycle = {tx_signal_ind_cycle},"
212
+ f"repetition = {tx_signal_ind_rep}", "BOLD")
213
+ print_update_wait(BLE4_BROADCAST_DURATION) # BLE5 configuration can take up to BLE4_BROADCAST_DURATION sec
214
+ # phase analysis #
215
+ mqtt_scan_n_create_log_file(test, (NUM_OF_SCANNING_CYCLE*tx_signal_ind_cycle) + SCAN_DELAY_TIME, phase, value=param.value)
216
+ expected_signal_ind_pkts = expected_signal_ind_pkts_calc(tx_brg_, rx_brg_)
217
+ received_signal_ind_pkts = get_all_signal_ind_pkt(test=test, rx_brg=rx_brg_, tx_brg=tx_brg_)
218
+ txt = f"""Phase {phase} - BRG {rx_brg_.id_str} signal indicator packets:
219
+ received {len(received_signal_ind_pkts)} packets, expected {expected_signal_ind_pkts} packets"""
220
+ print(txt)
221
+ if (not len(received_signal_ind_pkts) or
222
+ len(received_signal_ind_pkts) < expected_signal_ind_pkts or
223
+ len(received_signal_ind_pkts) > expected_signal_ind_pkts):
224
+ test.rc = TEST_FAILED
225
+ test.add_reason(txt)
226
+ test.set_phase_rc(param.name, test.rc)
227
+ test.add_phase_reason(param.name, test.reason)
228
+ field_functionality_pass_fail_print(test, 'phase', phase)
229
+ if test.rc == TEST_FAILED:
230
+ return terminate_test(test, phase=phase, revert_rx_brg=True,revert_tx_brg=True, modules=modules)
231
+
232
+ phase = 3
233
+ functionality_run_print(f"phase {phase}")
234
+ # Phase 3 - Rx BRG without tx.Expecting no signal indicator packets to be received.
235
+ tx_signal_ind_cycle, tx_signal_ind_rep = get_phase_tx_params_values(phase, TX_BRG_IDX)
236
+ utPrint(f"RX BRG without TX- cycle = {tx_signal_ind_cycle}, repetition = {tx_signal_ind_rep}\n", "BLUE")
237
+ # configuring transmitter to no TX #
238
+ utPrint(f"Configuring BRG {tx_brg_.id_str} to default", "BOLD")
239
+ transmitter_cfg_pkt = WltPkt(hdr=DEFAULT_HDR, pkt=tx_module(seq_id=random.randrange(99), brg_mac=tx_brg_.id_int,
240
+ signal_indicator_cycle=tx_signal_ind_cycle, signal_indicator_rep=tx_signal_ind_rep))
241
+ cert_config.brg_configure_ble5(test=test, cfg_pkt=transmitter_cfg_pkt, wait=False)
242
+ utPrint(f"BRG {tx_brg_.id_str} configured to default!!! cycle = {tx_signal_ind_cycle},"
243
+ f"repetition = {tx_signal_ind_rep}", "BOLD")
244
+ print_update_wait(BLE4_BROADCAST_DURATION) # BLE5 configuration can take up to BLE4_BROADCAST_DURATION sec
245
+ # phase analysis #
246
+ mqtt_scan_n_create_log_file(test, DEFAULT_SCAN_TIME, phase, value=param.value)
247
+ expected_signal_ind_pkts = 0
248
+ received_signal_ind_pkts = get_all_signal_ind_pkt(test=test, rx_brg=rx_brg_, tx_brg=tx_brg_)
249
+ if len(received_signal_ind_pkts) != expected_signal_ind_pkts:
250
+ test.rc = TEST_FAILED
251
+ test.add_reason(f"Phase {phase} failed - received signal indicator packet from BRG"
252
+ f"{rx_brg_.id_str}")
253
+ test.set_phase_rc(param.name, test.rc)
254
+ test.add_phase_reason(param.name, test.reason)
255
+ field_functionality_pass_fail_print(test, 'phase', phase)
256
+ if test.rc == TEST_FAILED:
257
+ return terminate_test(test, phase=phase, revert_rx_brg=True, revert_tx_brg=True, modules=modules)
258
+
259
+ if not test.internal_brg:
260
+ phase = 4
261
+ functionality_run_print(f"phase {phase}")
262
+ # Phase 4 - Both BRG's will be configured to be transmitters and receivers, with different tx params for each one.
263
+ # expecting to see signal indicator packets from both BRG's, according to the tx params.
264
+ utPrint(f"Both BRG's are transmitter and receivers, with different values\n", "BLUE")
265
+
266
+ # configuring first BRG (tx_brg_) #
267
+ tx_brg_signal_indicator_cycle, tx_brg_signal_indicator_rep = get_phase_tx_params_values(phase, TX_BRG_IDX)
268
+ # configuring first brg (tx_brg_) as receiver
269
+ utPrint(f"Configuring BRG {tx_brg_.id_str} as Signal Indicator Receiver", "BOLD")
270
+ cert_config.brg_configure_ble5(test=test, module=ext_sensors_module, fields=[BRG_SENSOR0], values=[ag.EXTERNAL_SENSORS_SIGNAL_INDICATOR], wait=False)
271
+ print_update_wait(BLE4_BROADCAST_DURATION) # BLE5 configuration can take up to BLE4_BROADCAST_DURATION sec
272
+ utPrint(f"BRG {tx_brg_.id_str} successfully configured as Signal Indicator Receiver\n", "BOLD")
273
+ # configuring first brg (tx_brg_) as transmitter
274
+ utPrint(f"Configuring BRG {tx_brg_.id_str} as Signal Indicator Transmitter", "BOLD")
275
+ transmitter_cfg_pkt = WltPkt(hdr=DEFAULT_HDR, pkt=tx_module(seq_id=random.randrange(99), brg_mac=tx_brg_.id_int,
276
+ signal_indicator_cycle=tx_brg_signal_indicator_cycle, signal_indicator_rep=tx_brg_signal_indicator_rep))
277
+ cert_config.brg_configure_ble5(test=test, cfg_pkt=transmitter_cfg_pkt, wait=False)
278
+ print_update_wait(BLE4_BROADCAST_DURATION) # BLE5 configuration can take up to BLE4_BROADCAST_DURATION sec
279
+ utPrint(f"BRG {tx_brg_.id_str} configured to be transmitter - cycle = {tx_brg_signal_indicator_cycle},"
280
+ f"repetition = {tx_brg_signal_indicator_rep}", "BOLD")
281
+
282
+ # configuring second brg (rx_brg_) as receiver
283
+ utPrint(f"Configuring BRG {rx_brg_.id_str} as Signal Indicator Receiver", "BOLD")
284
+ test = cert_config.brg1_configure(test=test, module=ext_sensors_module, fields=[BRG_SENSOR0], values=[ag.EXTERNAL_SENSORS_SIGNAL_INDICATOR], ble5=True)[0]
285
+ print_update_wait(BLE4_BROADCAST_DURATION) # BLE5 configuration can take up to BLE4_BROADCAST_DURATION sec
286
+ utPrint(f"BRG {rx_brg_.id_str} successfully configured as Signal Indicator Receiver\n", "BOLD")
287
+ rx_brg_signal_indicator_cycle, rx_brg_signal_indicator_rep = get_phase_tx_params_values(phase, RX_BRG_IDX)
288
+ # configuring second brg (rx_brg_) as transmitter
289
+ utPrint(f"Configuring BRG {rx_brg_.id_str} as Signal Indicator Transmitter", "BOLD")
290
+ transmitter_cfg_pkt = WltPkt(hdr=DEFAULT_HDR, pkt=tx_module(seq_id=random.randrange(99), brg_mac=rx_brg_.id_int,
291
+ signal_indicator_cycle=rx_brg_signal_indicator_cycle, signal_indicator_rep=rx_brg_signal_indicator_rep))
292
+ test = cert_config.brg1_configure(test=test, cfg_pkt=transmitter_cfg_pkt, ble5=True)[0]
293
+ if test.rc == TEST_FAILED and test.exit_on_param_failure:
294
+ test.add_reason(f"BRG {rx_brg_.id_str}: didn't receive signal indicator transmitter configuration!")
295
+ test.set_phase_rc(param.name, test.rc)
296
+ test.add_phase_reason(param.name, test.reason)
297
+ return terminate_test(test, phase=phase, revert_rx_brg=True,revert_tx_brg=True, modules=modules)
298
+ utPrint(f"BRG {tx_brg_.id_str} configured to be transmitter - cycle = {rx_brg_signal_indicator_cycle},"
299
+ f"repetition = {rx_brg_signal_indicator_rep}")
300
+
301
+ # phase analysis #
302
+ mqtt_scan_n_create_log_file(test, NUM_OF_SCANNING_CYCLE * max(tx_brg_signal_indicator_cycle, rx_brg_signal_indicator_cycle) + SCAN_DELAY_TIME, phase, value=param.value)
303
+
304
+ # Analysing tx_brg_ performance as receiver
305
+ rx_brg_tx_cycles = max(tx_brg_signal_indicator_cycle, rx_brg_signal_indicator_cycle) / rx_brg_signal_indicator_cycle
306
+ expected_signal_ind_pkts = int(expected_signal_ind_pkts_calc(rx_brg_, tx_brg_) * rx_brg_tx_cycles)
307
+ received_signal_ind_pkts = get_all_signal_ind_pkt(test=test, rx_brg=tx_brg_, tx_brg=rx_brg_)
308
+ txt = f"""Phase {phase} - BRG {tx_brg_.id_str} signal indicator packets:
309
+ received {len(received_signal_ind_pkts)} packets, expected {expected_signal_ind_pkts} packets"""
310
+ print(txt)
311
+ if (not len(received_signal_ind_pkts) or
312
+ len(received_signal_ind_pkts) < expected_signal_ind_pkts or
313
+ len(received_signal_ind_pkts) > expected_signal_ind_pkts):
314
+ test.rc = TEST_FAILED
315
+ test.add_reason(txt)
316
+ test.set_phase_rc(param.name, test.rc)
317
+ test.add_phase_reason(param.name, test.reason)
318
+ if test.rc == TEST_FAILED:
319
+ field_functionality_pass_fail_print(test, 'phase', phase)
320
+ return terminate_test(test, phase=phase, revert_rx_brg=True,revert_tx_brg=True, modules=modules)
321
+
322
+ # Analysing rx_brg_ performance as receiver
323
+ tx_brg_tx_cycles = max(tx_brg_signal_indicator_cycle, rx_brg_signal_indicator_cycle) / tx_brg_signal_indicator_cycle
324
+ expected_signal_ind_pkts = int(expected_signal_ind_pkts_calc(tx_brg_, rx_brg_) * tx_brg_tx_cycles)
325
+ received_signal_ind_pkts = get_all_signal_ind_pkt(test=test, rx_brg=rx_brg_, tx_brg=tx_brg_)
326
+ txt = f"""Phase {phase} - BRG {rx_brg_.id_str} signal indicator packets:
327
+ received {len(received_signal_ind_pkts)} packets, expected {expected_signal_ind_pkts} packets"""
328
+ print(txt)
329
+ if (not len(received_signal_ind_pkts) or
330
+ len(received_signal_ind_pkts) < expected_signal_ind_pkts or
331
+ len(received_signal_ind_pkts) > expected_signal_ind_pkts):
332
+ test.rc = TEST_FAILED
333
+ test.add_reason(txt)
334
+ test.set_phase_rc(param.name, test.rc)
335
+ test.add_phase_reason(param.name, test.reason)
336
+ if test.rc == TEST_FAILED:
337
+ field_functionality_pass_fail_print(test,'phase',phase)
338
+ return terminate_test(test, phase=phase, revert_rx_brg=True,revert_tx_brg=True, modules=modules)
339
+ field_functionality_pass_fail_print(test, 'phase', phase)
340
+
341
+ phase = 5 if not test.internal_brg else 4
342
+ functionality_run_print(f"phase {phase}")
343
+ # for internal_brg this is phase 4 !!!!!!!!!!!!!!!!
344
+ # Phase 5 - Tx BRG without rx. just waiting for packets to be sent from the transmitter and verify
345
+ # The receiver isn't receiving any signal indicator packets.
346
+ tx_signal_ind_cycle, tx_signal_ind_rep = get_phase_tx_params_values(5, TX_BRG_IDX)
347
+ utPrint(f"TX BRG without RX - cycle = {tx_signal_ind_cycle}, repetition = {tx_signal_ind_rep}\n", "BLUE")
348
+ # restore default configuration for receiver #
349
+ utPrint(f"Configuring BRG {rx_brg_.id_str} to default", "BOLD")
350
+ restore_modules = [modules[1]] if (test.internal_brg) else modules
351
+ test = cert_config.config_brg1_defaults(test, modules=restore_modules, ble5=True)[0]
352
+ print_update_wait(BLE4_BROADCAST_DURATION) # BLE5 configuration can take up to BLE4_BROADCAST_DURATION sec
353
+ if test.rc == TEST_FAILED and test.exit_on_param_failure:
354
+ test.add_reason(f"BRG {rx_brg_.id_str}: didn't revert to default configuration!")
355
+ test.set_phase_rc(param.name, test.rc)
356
+ test.add_phase_reason(param.name, test.reason)
357
+ return terminate_test(test, phase=phase, revert_rx_brg=True,revert_tx_brg=True, modules=modules)
358
+ # configuring transmitter #
359
+ utPrint(f"Configuring BRG {tx_brg_.id_str} as Signal Indicator Transmitter", "BOLD")
360
+ transmitter_cfg_pkt = WltPkt(hdr=DEFAULT_HDR, pkt=tx_module(seq_id=random.randrange(99), brg_mac=tx_brg_.id_int,
361
+ signal_indicator_cycle=tx_signal_ind_cycle, signal_indicator_rep=tx_signal_ind_rep))
362
+ cert_config.brg_configure_ble5(test=test, cfg_pkt=transmitter_cfg_pkt, wait=False)
363
+ print_update_wait(BLE4_BROADCAST_DURATION) # BLE5 configuration can take up to BLE4_BROADCAST_DURATION sec
364
+
365
+ # phase analysis #
366
+ mqtt_scan_n_create_log_file(test, (NUM_OF_SCANNING_CYCLE*tx_signal_ind_cycle) + SCAN_DELAY_TIME, phase, value=param.value)
367
+ expected_signal_ind_pkts = 0
368
+ received_signal_ind_pkts = get_all_signal_ind_pkt(test=test, rx_brg=rx_brg_, tx_brg=tx_brg_)
369
+ if len(received_signal_ind_pkts) != expected_signal_ind_pkts:
370
+ test.rc = TEST_FAILED
371
+ test.add_reason(f"Phase {phase} failed - received signal indicator packet from BRG"
372
+ f"{rx_brg_.id_str}")
373
+ test.set_phase_rc(param.name, test.rc)
374
+ test.add_phase_reason(param.name, test.reason)
375
+ field_functionality_pass_fail_print(test, 'phase', phase)
376
+ if test.rc == TEST_FAILED:
377
+ return terminate_test(test, phase=phase, revert_rx_brg=False, revert_tx_brg=True, modules=modules)
378
+
379
+ # Revert bridges to BLE4 before next loop
380
+ utPrint(f"reverting rx_brg {test.brg1.id_str} to defaults\n", "BOLD")
381
+ test, response = cert_config.config_brg1_defaults(test, modules=[datapath_module], ble5=True)
382
+ if response == NO_RESPONSE and test.exit_on_param_failure:
383
+ test.rc = TEST_FAILED
384
+ test.add_reason(f"BRG {test.brg1.id_str} didn't revert datapath_module to default configuration!")
385
+
386
+ utPrint(f"reverting tx_brg {test.brg0.id_str} to defaults\n", "BOLD")
387
+ test, response = cert_config.config_brg_defaults(test, modules=[datapath_module], ble5=True)
388
+ if response == NO_RESPONSE and test.exit_on_param_failure:
389
+ test.rc = TEST_FAILED
390
+ test.add_reason(f"BRG {test.brg0.id_str} didn't revert datapath module to default configuration!")
391
+
392
+ # Save the param result and reset the test result
393
+ test.set_phase_rc(param.name, test.rc)
394
+ test.add_phase_reason(param.name, test.reason)
395
+ test.reset_result()
396
+
397
+ # Test epilog
398
+ return terminate_test(test, phase=phase, revert_rx_brg=True, revert_tx_brg=True, modules=modules)
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "signal_indicator_functionality_sub1g_2_4_test",
3
+ "module": "energy2400",
4
+ "purpose": "TODO",
5
+ "documentaion": "<TEST_DOCUMENTATION_LINK>",
6
+ "initialCondition": "TODO",
7
+ "procedure": ["Test prolog", "TODO", "Test epilog"],
8
+ "expectedOutcome": "TODO",
9
+ "mandatory": 0,
10
+ "multiBridgeTest": 1,
11
+ "gwOnlyTest": 0,
12
+ "allSupportedValues": []
13
+ }
@@ -0,0 +1,153 @@
1
+ import random
2
+ from brg_certificate.cert_prints import *
3
+ from brg_certificate.cert_defines import *
4
+ import brg_certificate.cert_common as cert_common
5
+ import brg_certificate.cert_config as cert_config
6
+ from brg_certificate.wlt_types import *
7
+
8
+
9
+ # Test MACROS #
10
+ DEFAULT_HDR = ag.Hdr(group_id=ag.GROUP_ID_GW2BRG)
11
+ NUM_OF_SCANNING_CYCLE = 3
12
+ DEFAULT_SCAN_TIME = 60
13
+ SCAN_DELAY_TIME = 5
14
+ BOARD_TYPES_2_POLARIZATION_ANT_LIST = [ag.BOARD_TYPE_MINEW_SINGLE_BAND_V0, ag.BOARD_TYPE_MINEW_DUAL_BAND_V0, ag.BOARD_TYPE_ENERGOUS_V2, ag.BOARD_TYPE_ERM_V0, ag.BOARD_TYPE_ERM_V1]
15
+ ANTENNA_TYPE_2_4 = 0
16
+ ANTENNA_TYPE_SUB1G = 1
17
+ ANTENNA_TYPE_IDX = 21
18
+
19
+ # Test functions #
20
+ def mqtt_scan_n_create_log_file(test, duration):
21
+ test.mqttc.flush_pkts()
22
+ mqtt_scan_wait(test, duration=duration)
23
+ generate_log_file(test, "15&4")
24
+
25
+ def get_all_signal_ind_pkt(test=None, rx_brg=None, tx_brg=None):
26
+ if rx_brg == test.brg1:
27
+ all_sensor_packets = cert_mqtt.get_all_brg1_ext_sensor_pkts(mqttc=test.mqttc, test=test)
28
+ elif rx_brg == test.brg0:
29
+ all_sensor_packets = cert_mqtt.get_all_sensor_pkts(mqttc=test.mqttc, test=test)
30
+ signal_ind_pkts = []
31
+ for p in all_sensor_packets:
32
+ if p[SENSOR_UUID] == "{:06X}".format(ag.SENSOR_SERVICE_ID_SIGNAL_INDICATOR) and p[BRIDGE_ID] == rx_brg.id_str and (p[SENSOR_ID] == tx_brg.id_alias or p[SENSOR_ID] == tx_brg.id_str):
33
+ signal_ind_pkts.append(p)
34
+ return signal_ind_pkts
35
+
36
+ def expected_signal_ind_pkts_calc(tx_brg, rx_brg, antenna_type):
37
+ if (antenna_type == ANTENNA_TYPE_2_4 and tx_brg.board_type in BOARD_TYPES_2_POLARIZATION_ANT_LIST):
38
+ tx_brg_ant_polarization_num = 2
39
+ else:
40
+ tx_brg_ant_polarization_num = 1
41
+ if (antenna_type == ANTENNA_TYPE_2_4 and rx_brg.board_type in BOARD_TYPES_2_POLARIZATION_ANT_LIST):
42
+ rx_brg_ant_polarization_num = 2
43
+ else:
44
+ rx_brg_ant_polarization_num = 1
45
+ return NUM_OF_SCANNING_CYCLE * tx_brg_ant_polarization_num * rx_brg_ant_polarization_num
46
+
47
+ def terminate_test(test, revert_rx_brg=False, revert_tx_brg=False, rx_modules=[], tx_modules=[]):
48
+ # Temp solution for internal_brg test because test_epilog doesn't support both internal brg and test.brgs
49
+ utPrint("Terminating test!!!!!!!!\n", "BLUE")
50
+ if revert_rx_brg:
51
+ restore_modules = rx_modules
52
+ utPrint(f"reverting rx_brg {test.brg1.id_str} to defaults\n", "BOLD")
53
+ test, response = cert_config.config_brg1_defaults(test, modules=restore_modules)
54
+ if response == NO_RESPONSE and test.exit_on_param_failure:
55
+ test.rc = TEST_FAILED
56
+ test.add_reason(f"BRG {test.brg1.id_str} didn't revert modules "
57
+ f"{restore_modules} to default configuration!")
58
+
59
+ if revert_tx_brg:
60
+ restore_modules = tx_modules
61
+ utPrint(f"reverting tx_brg {test.brg0.id_str} to defaults\n", "BOLD")
62
+ test, response = cert_config.config_brg_defaults(test, modules=restore_modules)
63
+ if response == NO_RESPONSE and test.exit_on_param_failure:
64
+ test.rc = TEST_FAILED
65
+ test.add_reason(f"BRG {test.brg0.id_str} didn't revert modules"
66
+ f"{restore_modules} to default configuration!")
67
+ return cert_common.test_epilog(test)
68
+
69
+ # Test execution #
70
+ def run(test):
71
+
72
+ # Test modules evaluation #
73
+ energy2400_module = eval(f'ModuleEnergy2400V{test.active_brg.api_version}')
74
+ ext_sensors_module = eval(f'ModuleExtSensorsV{test.active_brg.api_version}')
75
+ energy_sub1g_module = eval(f'ModuleEnergySub1GV{test.active_brg.api_version}')
76
+
77
+ # Transmitter related defines #
78
+ tx_brg_ = test.brg0
79
+
80
+ # Receiver related defines #
81
+ rx_brg_ = test.brg1
82
+
83
+ # Test prolog
84
+ test = cert_common.test_prolog(test)
85
+ if test.rc == TEST_FAILED or test.reason != TEST_SUCCESS:
86
+ return terminate_test(test)
87
+
88
+ tx_signal_ind_cycle, tx_signal_ind_rep = 15, 4
89
+ utPrint(f"TX BRG with RX- cycle = {tx_signal_ind_cycle}, repetition = {tx_signal_ind_rep}\n", "HEADER")
90
+
91
+ # configuring receiver #
92
+ utPrint(f"Configuring BRG {rx_brg_.id_str} as Signal Indicator Receiver", "BOLD")
93
+ test = cert_config.brg1_configure(test=test, module=ext_sensors_module, fields=[BRG_SENSOR0], values=[ag.EXTERNAL_SENSORS_SIGNAL_INDICATOR])[0]
94
+ if test.rc == TEST_FAILED and test.exit_on_param_failure:
95
+ test.add_reason(f"BRG {rx_brg_.id_str}: didn't receive signal indicator receiver configuration!")
96
+ return terminate_test(test, revert_rx_brg=True, rx_modules=[ext_sensors_module])
97
+ utPrint(f"BRG {rx_brg_.id_str} succesfully configured to be receiver", "GREEN")
98
+
99
+ # configuring transmitter 2_4 #
100
+ utPrint(f"Configuring BRG {tx_brg_.id_str} as Signal Indicator 2_4 Transmitter", "BOLD")
101
+ transmitter_cfg_pkt_2_4 = WltPkt(hdr=DEFAULT_HDR, pkt=energy2400_module(seq_id=random.randrange(99), brg_mac=tx_brg_.id_int, signal_indicator_cycle=tx_signal_ind_cycle, signal_indicator_rep=tx_signal_ind_rep))
102
+ test = cert_config.brg_configure(test=test, cfg_pkt=transmitter_cfg_pkt_2_4)[0]
103
+ if test.rc == TEST_FAILED and test.exit_on_param_failure:
104
+ test.add_reason(f"BRG {tx_brg_.id_str}: didn't receive signal indicator 2_4 transmitter configuration!")
105
+ return terminate_test(test, revert_rx_brg=True,revert_tx_brg=True)
106
+ utPrint(f"BRG {tx_brg_.id_str} succesfully configured to be 2_4 transmitter - cycle = {tx_signal_ind_cycle},"
107
+ f"repetition = {tx_signal_ind_rep}", "GREEN")
108
+
109
+ # configuring transmitter sub1g #
110
+ utPrint(f"Configuring BRG {tx_brg_.id_str} as Signal Indicator sub1g Transmitter", "BOLD")
111
+ transmitter_cfg_pkt_sub1g = WltPkt(hdr=DEFAULT_HDR, pkt=energy_sub1g_module(seq_id=random.randrange(99), brg_mac=tx_brg_.id_int, signal_indicator_cycle=tx_signal_ind_cycle, signal_indicator_rep=tx_signal_ind_rep, pattern=ag.SUB1G_ENERGY_PATTERN_ISRAEL))
112
+ test = cert_config.brg_configure(test=test, cfg_pkt=transmitter_cfg_pkt_sub1g)[0]
113
+ if test.rc == TEST_FAILED and test.exit_on_param_failure:
114
+ test.add_reason(f"BRG {tx_brg_.id_str}: didn't receive signal indicator sub1g transmitter configuration!")
115
+ return terminate_test(test, revert_rx_brg=True,revert_tx_brg=True, rx_modules=[ext_sensors_module], tx_modules=[energy2400_module, energy_sub1g_module])
116
+ utPrint(f"BRG {tx_brg_.id_str} succesfully configured to be Sub1g transmitter - cycle = {tx_signal_ind_cycle},"
117
+ f"repetition = {tx_signal_ind_rep}, EP = {ag.SUB1G_ENERGY_PATTERN_ISRAEL}", "GREEN")
118
+
119
+ # analysis #
120
+ mqtt_scan_n_create_log_file(test, (NUM_OF_SCANNING_CYCLE * tx_signal_ind_cycle) + SCAN_DELAY_TIME)
121
+ received_signal_ind_pkts = get_all_signal_ind_pkt(test=test, rx_brg=rx_brg_, tx_brg=tx_brg_)
122
+ expected_signal_ind_2_4_pkts = expected_signal_ind_pkts_calc(tx_brg_, rx_brg_, ANTENNA_TYPE_2_4)
123
+ expected_signal_ind_sub1g_pkts = expected_signal_ind_pkts_calc(tx_brg_, rx_brg_, ANTENNA_TYPE_SUB1G)
124
+ signal_indicator_2_4_packets = 0
125
+ signal_indicator_sub1g_packets = 0
126
+ for p in received_signal_ind_pkts:
127
+ if int(p[PAYLOAD][ANTENNA_TYPE_IDX]) == ANTENNA_TYPE_SUB1G and p[SENSOR_ID] == tx_brg_.id_str:
128
+ signal_indicator_sub1g_packets += 1
129
+ elif int(p[PAYLOAD][ANTENNA_TYPE_IDX]) == ANTENNA_TYPE_2_4 and p[SENSOR_ID] == tx_brg_.id_alias:
130
+ signal_indicator_2_4_packets += 1
131
+ utPrint(f"Received {signal_indicator_2_4_packets} 2_4 signal indicator packets and {signal_indicator_sub1g_packets} subg signal indicator packets", "BLUE")
132
+
133
+ # Test evaluation #
134
+ if len(received_signal_ind_pkts) < expected_signal_ind_2_4_pkts + expected_signal_ind_sub1g_pkts:
135
+ test.rc = TEST_FAILED
136
+ test.add_reason(f"Test failed - BRG {rx_brg_.id_str} received wrong number of "
137
+ f"total signal indicator packets\n received {len(received_signal_ind_pkts)} packets, "
138
+ f"expected {expected_signal_ind_2_4_pkts + expected_signal_ind_sub1g_pkts} packets")
139
+ elif signal_indicator_2_4_packets < expected_signal_ind_2_4_pkts:
140
+ test.rc = TEST_FAILED
141
+ test.add_reason(f"Test failed - BRG {rx_brg_.id_str} received wrong number of "
142
+ f"signal indicator 2.4 packets\n received {signal_indicator_2_4_packets} packets, "
143
+ f"expected {expected_signal_ind_2_4_pkts} packets")
144
+ elif signal_indicator_sub1g_packets < expected_signal_ind_sub1g_pkts:
145
+ test.rc = TEST_FAILED
146
+ test.add_reason(f"Test failed - BRG {rx_brg_.id_str} received wrong number of "
147
+ f"signal indicator sub1g packets\n received {signal_indicator_sub1g_packets} packets, "
148
+ f"expected {expected_signal_ind_sub1g_pkts} packets")
149
+
150
+ field_functionality_pass_fail_print(test,'Signal Indicator Functionality 2_4 & Sub1g')
151
+
152
+ # Test epilog
153
+ return terminate_test(test, revert_rx_brg=False,revert_tx_brg=True, rx_modules=[ext_sensors_module], tx_modules=[energy2400_module, energy_sub1g_module])
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "signal_indicator_functionality_test",
3
+ "module": "energy2400",
4
+ "purpose": "TODO",
5
+ "documentaion": "<TEST_DOCUMENTATION_LINK>",
6
+ "initialCondition": "TODO",
7
+ "procedure": ["Test prolog", "TODO", "Test epilog"],
8
+ "expectedOutcome": "TODO",
9
+ "mandatory": 0,
10
+ "multiBridgeTest": 1,
11
+ "gwOnlyTest": 0,
12
+ "allSupportedValues": ["rssi_threshold", "brg0_rx_brg1_tx", "brg0_none_brg1_rx", "brg0_rxtx_brg1_rxtx", "brg0_tx_brg1_none"]
13
+ }