wiliot-certificate 1.4.0a2__py3-none-any.whl → 1.5.1a1__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.
- brg_certificate/ag/energous_v0_defines.py +28 -28
- brg_certificate/ag/energous_v1_defines.py +28 -28
- brg_certificate/ag/energous_v2_defines.py +28 -28
- brg_certificate/ag/energous_v3_defines.py +28 -28
- brg_certificate/ag/energous_v4_defines.py +28 -28
- brg_certificate/ag/fanstel_lan_v0_defines.py +28 -28
- brg_certificate/ag/fanstel_lte_v0_defines.py +28 -28
- brg_certificate/ag/fanstel_wifi_v0_defines.py +28 -28
- brg_certificate/ag/minew_lte_v0_defines.py +28 -28
- brg_certificate/ag/wlt_cmd_if.html +1 -1
- brg_certificate/ag/wlt_types.html +3 -4
- brg_certificate/ag/wlt_types_ag.py +162 -163
- brg_certificate/brg_certificate.py +46 -12
- brg_certificate/brg_certificate_cli.py +1 -0
- brg_certificate/cert_common.py +31 -42
- brg_certificate/cert_config.py +7 -5
- brg_certificate/cert_data_sim.py +26 -4
- brg_certificate/cert_defines.py +30 -3
- brg_certificate/cert_gw_sim.py +12 -8
- brg_certificate/cert_mqtt.py +10 -2
- brg_certificate/cert_prints.py +7 -5
- brg_certificate/cert_protobuf.py +5 -1
- brg_certificate/cert_results.py +134 -84
- brg_certificate/cert_utils.py +14 -17
- brg_certificate/certificate_bcc_sanity_test_list.txt +35 -0
- brg_certificate/certificate_bcc_test_list.txt +45 -0
- brg_certificate/certificate_sanity_test_list.txt +2 -1
- brg_certificate/certificate_test_list.txt +10 -4
- brg_certificate/restore_brg.py +2 -0
- brg_certificate/tests/calibration/interval_test/interval_test.json +2 -1
- brg_certificate/tests/calibration/interval_test/interval_test.py +1 -1
- brg_certificate/tests/calibration/output_power_test/output_power_test.json +5 -3
- brg_certificate/tests/calibration/output_power_test/output_power_test.py +1 -1
- brg_certificate/tests/calibration/pattern_test/pattern_test.json +5 -2
- brg_certificate/tests/calibration/pattern_test/pattern_test.py +1 -1
- brg_certificate/tests/datapath/aging_test/aging_test.json +20 -0
- brg_certificate/tests/datapath/aging_test/aging_test.py +135 -0
- brg_certificate/tests/datapath/num_of_tags_test/num_of_tags_test.json +8 -3
- brg_certificate/tests/datapath/num_of_tags_test/num_of_tags_test.py +2 -2
- brg_certificate/tests/datapath/output_power_test/output_power_test.json +5 -2
- brg_certificate/tests/datapath/output_power_test/output_power_test.py +1 -1
- brg_certificate/tests/datapath/pacer_interval_ble5_test/pacer_interval_ble5_test.json +5 -2
- brg_certificate/tests/datapath/pacer_interval_ble5_test/pacer_interval_ble5_test.py +1 -1
- brg_certificate/tests/datapath/pacer_interval_tags_count_test/pacer_interval_tags_count_test.json +5 -2
- brg_certificate/tests/datapath/pacer_interval_tags_count_test/pacer_interval_tags_count_test.py +2 -2
- brg_certificate/tests/datapath/pacer_interval_test/pacer_interval_test.json +5 -2
- brg_certificate/tests/datapath/pacer_interval_test/pacer_interval_test.py +1 -1
- brg_certificate/tests/datapath/pattern_test/pattern_test.json +6 -3
- brg_certificate/tests/datapath/pattern_test/pattern_test.py +1 -1
- brg_certificate/tests/datapath/pkt_filter_ble5_test/pkt_filter_ble5_test.json +8 -2
- brg_certificate/tests/datapath/pkt_filter_ble5_test/pkt_filter_ble5_test.py +1 -1
- brg_certificate/tests/datapath/pkt_filter_gen3_test/pkt_filter_gen3_test.json +8 -2
- brg_certificate/tests/datapath/pkt_filter_gen3_test/pkt_filter_gen3_test.py +1 -1
- brg_certificate/tests/datapath/pkt_filter_test/pkt_filter_test.json +8 -2
- brg_certificate/tests/datapath/pkt_filter_test/pkt_filter_test.py +1 -1
- brg_certificate/tests/datapath/rssi_threshold_test/rssi_threshold_test.json +6 -2
- brg_certificate/tests/datapath/rssi_threshold_test/rssi_threshold_test.py +1 -1
- brg_certificate/tests/datapath/rx_channel_test/rx_channel_test.json +5 -2
- brg_certificate/tests/datapath/rx_channel_test/rx_channel_test.py +1 -1
- brg_certificate/tests/datapath/rx_rate_gen2_test/rx_rate_gen2_test.json +3 -4
- brg_certificate/tests/datapath/rx_rate_gen2_test/rx_rate_gen2_test.py +1 -1
- brg_certificate/tests/datapath/rx_rate_gen3_test/rx_rate_gen3_test.json +3 -4
- brg_certificate/tests/datapath/rx_rate_gen3_test/rx_rate_gen3_test.py +1 -1
- brg_certificate/tests/datapath/stress_gen3_test/stress_gen3_test.json +14 -22
- brg_certificate/tests/datapath/stress_gen3_test/stress_gen3_test.py +24 -24
- brg_certificate/tests/datapath/stress_test/stress_test.json +11 -18
- brg_certificate/tests/datapath/stress_test/stress_test.py +20 -27
- brg_certificate/tests/datapath/tx_repetition_algo_test/tx_repetition_algo_test.json +6 -2
- brg_certificate/tests/datapath/tx_repetition_algo_test/tx_repetition_algo_test.py +1 -1
- brg_certificate/tests/datapath/tx_repetition_test/tx_repetition_test.json +6 -2
- brg_certificate/tests/datapath/tx_repetition_test/tx_repetition_test.py +1 -1
- brg_certificate/tests/edge_mgmt/actions_test/actions_test.json +2 -1
- brg_certificate/tests/edge_mgmt/actions_test/actions_test.py +4 -24
- brg_certificate/tests/edge_mgmt/brg2brg_ota_ble5_test/brg2brg_ota_ble5_test.json +2 -1
- brg_certificate/tests/edge_mgmt/brg2brg_ota_ble5_test/brg2brg_ota_ble5_test.py +1 -1
- brg_certificate/tests/edge_mgmt/brg2brg_ota_test/brg2brg_ota_test.json +2 -1
- brg_certificate/tests/edge_mgmt/brg2brg_ota_test/brg2brg_ota_test.py +1 -1
- brg_certificate/tests/edge_mgmt/leds_test/leds_test.json +9 -5
- brg_certificate/tests/edge_mgmt/leds_test/leds_test.py +4 -4
- brg_certificate/tests/edge_mgmt/ota_test/ota_test.json +9 -5
- brg_certificate/tests/edge_mgmt/ota_test/ota_test.py +45 -1
- brg_certificate/tests/edge_mgmt/stat_test/stat_test.json +2 -1
- brg_certificate/tests/edge_mgmt/stat_test/stat_test.py +1 -1
- brg_certificate/tests/energy2400/duty_cycle_test/duty_cycle_test.json +5 -2
- brg_certificate/tests/energy2400/duty_cycle_test/duty_cycle_test.py +1 -1
- brg_certificate/tests/energy2400/output_power_test/output_power_test.json +5 -3
- brg_certificate/tests/energy2400/output_power_test/output_power_test.py +1 -1
- brg_certificate/tests/energy2400/pattern_test/pattern_test.json +5 -2
- brg_certificate/tests/energy2400/pattern_test/pattern_test.py +1 -1
- brg_certificate/tests/energy2400/signal_indicator_ble5_10_250k_test/signal_indicator_ble5_10_250k_test.json +20 -0
- brg_certificate/tests/energy2400/signal_indicator_ble5_10_250k_test/signal_indicator_ble5_10_250k_test.py +346 -0
- brg_certificate/tests/energy2400/signal_indicator_ble5_10_500k_test/signal_indicator_ble5_10_500k_test.json +20 -0
- brg_certificate/tests/energy2400/signal_indicator_ble5_10_500k_test/signal_indicator_ble5_10_500k_test.py +346 -0
- brg_certificate/tests/energy2400/signal_indicator_sub1g_2_4_test/signal_indicator_sub1g_2_4_test.json +2 -1
- brg_certificate/tests/energy2400/signal_indicator_sub1g_2_4_test/signal_indicator_sub1g_2_4_test.py +1 -1
- brg_certificate/tests/energy2400/signal_indicator_test/signal_indicator_test.json +12 -5
- brg_certificate/tests/energy2400/signal_indicator_test/signal_indicator_test.py +130 -43
- brg_certificate/tests/energy_sub1g/duty_cycle_test/duty_cycle_test.json +5 -2
- brg_certificate/tests/energy_sub1g/duty_cycle_test/duty_cycle_test.py +1 -1
- brg_certificate/tests/energy_sub1g/pattern_test/pattern_test.json +9 -3
- brg_certificate/tests/energy_sub1g/pattern_test/pattern_test.py +1 -1
- brg_certificate/tests/energy_sub1g/signal_indicator_functionality_test/signal_indicator_functionality_test.json +2 -1
- brg_certificate/tests/energy_sub1g/signal_indicator_functionality_test/signal_indicator_functionality_test.py +1 -1
- brg_certificate/tests/energy_sub1g/signal_indicator_test/signal_indicator_test.json +5 -2
- brg_certificate/tests/energy_sub1g/signal_indicator_test/signal_indicator_test.py +1 -1
- brg_certificate/wltPb_pb2.py +50 -38
- brg_certificate/wltPb_pb2.pyi +40 -34
- brg_certificate/wlt_types.py +4 -6
- common/wlt_logo.png +0 -0
- gw_certificate/ag/ut_defines.py +4 -1
- gw_certificate/cert_results.py +145 -0
- gw_certificate/gw_certificate.py +18 -6
- gw_certificate/gw_certificate_cli.py +3 -3
- gw_certificate/interface/mqtt.py +1 -0
- gw_certificate/interface/uart_if.py +1 -1
- gw_certificate/tests/actions.py +7 -2
- gw_certificate/tests/connection.py +1 -1
- gw_certificate/tests/generic.py +43 -17
- gw_certificate/tests/registration.py +2 -1
- gw_certificate/tests/uplink.py +26 -35
- {wiliot_certificate-1.4.0a2.dist-info → wiliot_certificate-1.5.1a1.dist-info}/METADATA +16 -10
- {wiliot_certificate-1.4.0a2.dist-info → wiliot_certificate-1.5.1a1.dist-info}/RECORD +126 -120
- {wiliot_certificate-1.4.0a2.dist-info → wiliot_certificate-1.5.1a1.dist-info}/WHEEL +1 -1
- {wiliot_certificate-1.4.0a2.dist-info → wiliot_certificate-1.5.1a1.dist-info}/top_level.txt +1 -0
- brg_certificate/tests/datapath/adaptive_pacer_algo_test/adaptive_pacer_algo_test.json +0 -13
- brg_certificate/tests/datapath/adaptive_pacer_algo_test/adaptive_pacer_algo_test.py +0 -76
- brg_certificate/tests/energy2400/signal_indicator_ble5_test/signal_indicator_ble5_test.json +0 -13
- brg_certificate/tests/energy2400/signal_indicator_ble5_test/signal_indicator_ble5_test.py +0 -398
- {wiliot_certificate-1.4.0a2.dist-info → wiliot_certificate-1.5.1a1.dist-info}/entry_points.txt +0 -0
- {wiliot_certificate-1.4.0a2.dist-info → wiliot_certificate-1.5.1a1.dist-info/licenses}/LICENSE +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import sys
|
|
4
4
|
import os
|
|
5
5
|
sys.path.insert(0, os.path.abspath(".."))
|
|
6
|
-
import
|
|
6
|
+
import webbrowser
|
|
7
7
|
import glob
|
|
8
8
|
import datetime
|
|
9
9
|
import tabulate
|
|
@@ -38,6 +38,8 @@ def skip_test_check(test, args):
|
|
|
38
38
|
skip_string = ""
|
|
39
39
|
if test.multi_brg and not test.brg1:
|
|
40
40
|
skip_string = f"Skipped {test.module_name} multi brg test because brg1 wasn't given"
|
|
41
|
+
elif (args.brg_cloud_connectivity or test.internal_brg) and not test.test_json[INTERNAL_BRG]:
|
|
42
|
+
skip_string = f"Skipped {test.module_name} because test is unable to run on an internal brg"
|
|
41
43
|
elif args.skip_internal and test.internal_brg:
|
|
42
44
|
skip_string = f"Skipped {test.module_name} for internal brg because skip_internal flag is set"
|
|
43
45
|
elif test.active_brg and not test.active_brg.is_sup_cap(test):
|
|
@@ -86,7 +88,16 @@ def main(args):
|
|
|
86
88
|
sys.exit(0)
|
|
87
89
|
|
|
88
90
|
# Init mqtt client
|
|
89
|
-
|
|
91
|
+
if args.brg_cloud_connectivity:
|
|
92
|
+
# Mqtt client for tested device
|
|
93
|
+
mqttc = cert_mqtt.mqttc_init(args.brg_cloud_connectivity, data=args.data)
|
|
94
|
+
# Mqtt client for testing device
|
|
95
|
+
sim_mqttc = cert_mqtt.mqttc_init(args.gw, data=args.data)
|
|
96
|
+
else:
|
|
97
|
+
# Single mqtt client for a single device with cloud connectivity
|
|
98
|
+
mqttc = cert_mqtt.mqttc_init(args.gw, data=args.data)
|
|
99
|
+
sim_mqttc = mqttc
|
|
100
|
+
|
|
90
101
|
|
|
91
102
|
# Run Gateway Simulator in separated thread if exists
|
|
92
103
|
gw_sim_thread = None
|
|
@@ -105,12 +116,29 @@ def main(args):
|
|
|
105
116
|
|
|
106
117
|
# Prepare GW
|
|
107
118
|
if gw_sim_thread:
|
|
108
|
-
|
|
119
|
+
if args.brg_cloud_connectivity:
|
|
120
|
+
# Prepare tested device
|
|
121
|
+
gw, internal_brg, gw_server, gw_version, protobuf = ut_prep_gw(args, mqttc, start_time)
|
|
122
|
+
# Prepare testing device
|
|
123
|
+
_, internal_brg_sim, _, _, _ = cert_gw_sim.prep_gw(args, sim_mqttc, start_time)
|
|
124
|
+
else:
|
|
125
|
+
# Prepare single device with cloud connectivity
|
|
126
|
+
gw, internal_brg, gw_server, gw_version, protobuf = cert_gw_sim.prep_gw(args, mqttc, start_time)
|
|
109
127
|
else:
|
|
110
|
-
|
|
128
|
+
if args.brg_cloud_connectivity:
|
|
129
|
+
# Prepare tested device
|
|
130
|
+
gw, internal_brg, gw_server, gw_version, protobuf = ut_prep_gw(args, mqttc, start_time)
|
|
131
|
+
# Prepare testing device
|
|
132
|
+
_, internal_brg_sim, _, _, _ = ut_prep_gw(args, sim_mqttc, start_time, tester_gw=True)
|
|
133
|
+
else:
|
|
134
|
+
# Prepare single device with cloud connectivity
|
|
135
|
+
gw, internal_brg, gw_server, gw_version, protobuf = ut_prep_gw(args, mqttc, start_time)
|
|
111
136
|
|
|
112
137
|
brg0, brg1 = None, None
|
|
113
|
-
if args.
|
|
138
|
+
if args.brg_cloud_connectivity:
|
|
139
|
+
brg0 = internal_brg
|
|
140
|
+
internal_brg = internal_brg_sim
|
|
141
|
+
elif args.brg:
|
|
114
142
|
brg0 = ut_prep_brg(args, mqttc, start_time, gw, args.brg, gw_server, protobuf)
|
|
115
143
|
if args.brg1:
|
|
116
144
|
brg1 = ut_prep_brg(args, mqttc, start_time, gw, args.brg1, gw_server, protobuf)
|
|
@@ -119,7 +147,7 @@ def main(args):
|
|
|
119
147
|
tests = []
|
|
120
148
|
for l in open(os.path.join(BASE_DIR, test_list)).readlines():
|
|
121
149
|
if l.strip() and not l.strip().startswith("#"):
|
|
122
|
-
test = (WltTest(l.strip(), gw, mqttc, exit_on_param_failure=args.exit_on_param_failure, gw_lan=args.lan,
|
|
150
|
+
test = (WltTest(l.strip(), gw, mqttc, sim_mqttc=sim_mqttc, exit_on_param_failure=args.exit_on_param_failure, gw_lan=args.lan,
|
|
123
151
|
gw_orig_versions={BLE_VERSION:gw_version[BLE_VERSION], WIFI_VERSION:gw_version[WIFI_VERSION]},
|
|
124
152
|
server=gw_server, latest=args.latest, release_candidate=args.rc, private_setup=args.private_setup, internal_brg_obj=internal_brg,
|
|
125
153
|
gw_sim=gw_sim_thread, data=args.data, port=args.port, protobuf=protobuf))
|
|
@@ -150,13 +178,15 @@ def main(args):
|
|
|
150
178
|
test_module_name = load_module(f'{test.module_name}.py', f'{test.dir}/{test.module_name}.py')
|
|
151
179
|
test = skip_test_check(test, args)
|
|
152
180
|
if test.rc == TEST_SKIPPED:
|
|
181
|
+
for phase in test.phases:
|
|
182
|
+
phase.rc = TEST_SKIPPED
|
|
153
183
|
skipped += 1
|
|
154
184
|
else:
|
|
155
185
|
test = test_module_name.run(test)
|
|
156
186
|
test.update_overall_rc()
|
|
157
187
|
if test.rc == TEST_FAILED:
|
|
158
188
|
failures += 1
|
|
159
|
-
if "versions_test" in test.module_name and "EXITING
|
|
189
|
+
if "versions_test" in test.module_name and f"EXITING CERTIFICATE" in test.reason:
|
|
160
190
|
exit_on_test_failure = True
|
|
161
191
|
print(f"Test Duration: {test.duration}")
|
|
162
192
|
print(tabulate.tabulate([[i+1, i+1-(failures+skipped), skipped, failures, len(tests)]],
|
|
@@ -177,12 +207,16 @@ def main(args):
|
|
|
177
207
|
print(tabulate.tabulate([[i+1, i+1-(failures+skipped), skipped, failures, len(tests)]],
|
|
178
208
|
headers=["FINISHED", "PASSED", "SKIPPED", "FAILED", "TOTAL"], tablefmt="pretty"))
|
|
179
209
|
|
|
180
|
-
print(
|
|
210
|
+
print(WIL_CERT_TEXT)
|
|
181
211
|
print_warn(get_important_tests_info())
|
|
182
|
-
print_pass_or_fail(not failures, "Wiliot
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
212
|
+
print_pass_or_fail(not failures, f"Wiliot Certificate")
|
|
213
|
+
|
|
214
|
+
pipeline = cert_common.pipeline_running()
|
|
215
|
+
# brg = args.brg_cloud_connectivity if args.brg_cloud_connectivity else args.brg
|
|
216
|
+
cert_results.generate_results_files(html=True, pdf=True, failures=failures, skipped=skipped, start_time=start_time, duration=duration,
|
|
217
|
+
brg=test.active_brg, internal_brg=internal_brg, tests=tests, pipeline=pipeline)
|
|
218
|
+
if not pipeline:
|
|
219
|
+
webbrowser.open('file://' + os.path.realpath(os.path.join(BASE_DIR, UT_RESULT_FILE_PDF)))
|
|
186
220
|
|
|
187
221
|
if failures:
|
|
188
222
|
sys.exit(-1)
|
|
@@ -13,6 +13,7 @@ class BrgCertificateCLI:
|
|
|
13
13
|
description="Bridge Certificate CLI",
|
|
14
14
|
)
|
|
15
15
|
self.parser.add_argument('--brg', '-b', default="", help='Bridge id to run on the tests')
|
|
16
|
+
self.parser.add_argument('--brg_cloud_connectivity', '-bcc', default="", help='Bridge with cloud connectivity id to run on the tests')
|
|
16
17
|
self.parser.add_argument('--brg1', '-b1', default="", help='Second bridge id to run on tests two bridges needed')
|
|
17
18
|
self.parser.add_argument('--gw', '-g', type=str, required=True, help='GW id to run on the test, SIM prefix is used for Gateway simulation')
|
|
18
19
|
self.parser.add_argument('--data', '-d', choices=[DATA_REAL_TAGS, DATA_SIMULATION], default=DATA_REAL_TAGS, help='Choose if data generated from real tags or by simulation')
|
brg_certificate/cert_common.py
CHANGED
|
@@ -13,7 +13,7 @@ import math, random
|
|
|
13
13
|
DEFAULT_HDR = ag.Hdr(group_id=ag.GROUP_ID_GW2BRG)
|
|
14
14
|
|
|
15
15
|
# Returns a 12 chars long hex string
|
|
16
|
-
int2mac_get = lambda int_val: "{:012X}"
|
|
16
|
+
int2mac_get = lambda int_val: f"{int_val:012X}"
|
|
17
17
|
|
|
18
18
|
def name_to_val(name):
|
|
19
19
|
return globals()[name]
|
|
@@ -35,8 +35,8 @@ def test_prolog(test):
|
|
|
35
35
|
test.mqttc.flush_pkts()
|
|
36
36
|
|
|
37
37
|
#TODO - remove/check status later on in the test
|
|
38
|
-
test.set_phase_rc(
|
|
39
|
-
test.add_phase_reason(
|
|
38
|
+
test.set_phase_rc(PRE_CONFIG, rc=test.rc)
|
|
39
|
+
test.add_phase_reason(PRE_CONFIG, reason=test.reason)
|
|
40
40
|
#
|
|
41
41
|
|
|
42
42
|
return test
|
|
@@ -59,37 +59,37 @@ def test_epilog(test, revert_brgs=False, revert_gws=False, modules=[], brg1_modu
|
|
|
59
59
|
test.add_phase_reason(TEST_BODY, test.reason)
|
|
60
60
|
|
|
61
61
|
test.reset_result()
|
|
62
|
-
test.set_phase_rc(
|
|
62
|
+
test.set_phase_rc(RESTORE_CONFIG, TEST_PASSED)
|
|
63
63
|
|
|
64
64
|
if revert_brgs:
|
|
65
65
|
res2 = DONE
|
|
66
66
|
test, res = cert_config.config_brg_defaults(test, modules=modules, ble5=ble5)
|
|
67
67
|
# TODO - REMOVE when rc is re-designed
|
|
68
|
-
test.set_phase_rc(
|
|
68
|
+
test.set_phase_rc(RESTORE_CONFIG, test.rc)
|
|
69
69
|
test.reset_result()
|
|
70
70
|
#
|
|
71
71
|
if test.brg1 and test.multi_brg:
|
|
72
72
|
brg1_modules = modules if not brg1_modules else brg1_modules
|
|
73
73
|
test, res2 = cert_config.config_brg1_defaults(test, modules=brg1_modules)
|
|
74
74
|
# TODO - REMOVE when rc is re-designed
|
|
75
|
-
test.set_phase_rc(
|
|
75
|
+
test.set_phase_rc(RESTORE_CONFIG, test.rc)
|
|
76
76
|
test.reset_result()
|
|
77
77
|
#
|
|
78
78
|
if res == NO_RESPONSE or res2 == NO_RESPONSE:
|
|
79
79
|
txt = "Failed: Revert BRGs to defaults"
|
|
80
80
|
utPrint(txt, "RED")
|
|
81
|
-
test.add_phase_reason(
|
|
81
|
+
test.add_phase_reason(RESTORE_CONFIG, txt)
|
|
82
82
|
|
|
83
83
|
if revert_gws:
|
|
84
84
|
test, res = cert_config.config_gw_defaults(test)
|
|
85
85
|
# TODO - REMOVE when rc is re-designed
|
|
86
|
-
test.set_phase_rc(
|
|
86
|
+
test.set_phase_rc(RESTORE_CONFIG, test.rc)
|
|
87
87
|
test.reset_result()
|
|
88
88
|
#
|
|
89
89
|
if res == NO_RESPONSE:
|
|
90
90
|
txt = "Failed: Revert GW to defaults"
|
|
91
91
|
utPrint(txt, "RED")
|
|
92
|
-
test.add_phase_reason(
|
|
92
|
+
test.add_phase_reason(RESTORE_CONFIG, txt)
|
|
93
93
|
|
|
94
94
|
test.mqttc.flush_pkts()
|
|
95
95
|
test.end_time = datetime.datetime.now()
|
|
@@ -101,7 +101,7 @@ def test_epilog(test, revert_brgs=False, revert_gws=False, modules=[], brg1_modu
|
|
|
101
101
|
and test.get_phase_rc(TEST_BODY) == TEST_FAILED):
|
|
102
102
|
print("Setting rc to TEST_PASSED for pipeline after BRG OTA succeeded")
|
|
103
103
|
test.set_phase_rc(TEST_BODY, TEST_PASSED)
|
|
104
|
-
test.set_phase_rc(
|
|
104
|
+
test.set_phase_rc(RESTORE_CONFIG, TEST_PASSED)
|
|
105
105
|
|
|
106
106
|
test_epilog_print(test)
|
|
107
107
|
return test
|
|
@@ -259,7 +259,11 @@ time_in_sec = lambda t : t.seconds + t.microseconds / 1000000
|
|
|
259
259
|
|
|
260
260
|
def get_all_brg_pkts(test):
|
|
261
261
|
utPrint(f"Collecting all BRG pkts", "BLUE")
|
|
262
|
-
return cert_mqtt.get_unified_data_pkts(test)
|
|
262
|
+
return cert_mqtt.get_unified_data_pkts(test, only_active_brg=True)
|
|
263
|
+
|
|
264
|
+
def get_all_brgs_pkts(test):
|
|
265
|
+
utPrint(f"Collecting all BRG pkts", "BLUE")
|
|
266
|
+
return cert_mqtt.get_unified_data_pkts(test, only_active_brg=False)
|
|
263
267
|
|
|
264
268
|
def get_pkts_data_frame(test, gw_data=False, brg_data=False, per_pkt_type=False):
|
|
265
269
|
pkts = []
|
|
@@ -435,7 +439,7 @@ def pacing_analysis(test, pacer_interval, df, pkt_filter_cfg=ag.PKT_FILTER_RANDO
|
|
|
435
439
|
if test.data == DATA_SIMULATION and (avg_pacer / pacer_interval) > PACER_INTERVAL_CEIL_THRESHOLD:
|
|
436
440
|
failed_tags += 1
|
|
437
441
|
print(f"Tag {tag} with diff_time {list(pkts.timestamp.diff().div(1000))}, avg_pacer={avg_pacer} exceeds {PACER_INTERVAL_CEIL_THRESHOLD} maximum threshold!")
|
|
438
|
-
if failed_tags >
|
|
442
|
+
if failed_tags/tags_count > 0.2: # Fail the test on ceil threshold only when more than 20 % tag failed
|
|
439
443
|
test.rc = TEST_FAILED
|
|
440
444
|
|
|
441
445
|
# PASS test if only 1 tag out of many failed - this could be an issue with the tag
|
|
@@ -523,12 +527,14 @@ def scan_for_mgmt_pkts(test, mgmt_type):
|
|
|
523
527
|
print_update_wait()
|
|
524
528
|
pkts_collected = cert_mqtt.get_brg2gw_mgmt_pkts(test.mqttc, test, mgmt_types=mgmt_type)
|
|
525
529
|
if pkts_collected:
|
|
526
|
-
|
|
530
|
+
#TODO: logging print
|
|
531
|
+
# utPrint("Found brg2gw_mgmt_pkts:", "GREEN")
|
|
527
532
|
seq_ids = []
|
|
528
533
|
for p in pkts_collected:
|
|
529
534
|
if seq_ids == [] or p[SEQUENCE_ID] not in seq_ids:
|
|
530
535
|
seq_ids.append(p[SEQUENCE_ID])
|
|
531
|
-
print
|
|
536
|
+
#TODO: Logging print
|
|
537
|
+
# print(p[MGMT_PKT].pkt)
|
|
532
538
|
ret_pkts.append(p)
|
|
533
539
|
found = True
|
|
534
540
|
break
|
|
@@ -591,7 +597,7 @@ def display_data(df, csv=True, nfpkt=False, pkt_cntr_diff=False, cer_per_tag=Fal
|
|
|
591
597
|
f.write(g.to_html(full_html=False, include_plotlyjs='cdn', include_mathjax='cdn'))
|
|
592
598
|
f.write("<br>")
|
|
593
599
|
if csv:
|
|
594
|
-
df.to_csv(os.path.join(dir, f"{name_prefix}all_data.csv"), index=False)
|
|
600
|
+
df.to_csv(os.path.join(BASE_DIR, dir, f"{name_prefix}all_data.csv"), index=False)
|
|
595
601
|
|
|
596
602
|
return ttfp_graph
|
|
597
603
|
|
|
@@ -599,7 +605,11 @@ def single_log_search(test, s, found, fail_on_find=False, print_logs=True, addit
|
|
|
599
605
|
res = False
|
|
600
606
|
for p in test.mqttc._userdata[PKTS].status:
|
|
601
607
|
if GW_LOGS in p.body:
|
|
602
|
-
|
|
608
|
+
if test.protobuf and p.body[GW_LOGS]:
|
|
609
|
+
# handle protobuf structure (when GW_LOGS is not empty)
|
|
610
|
+
logs = p.body[GW_LOGS][LOGS]
|
|
611
|
+
else:
|
|
612
|
+
logs = p.body[GW_LOGS]
|
|
603
613
|
for log in logs:
|
|
604
614
|
if any([s in log]) and any([additional_log in log]) and (log not in found):
|
|
605
615
|
print(f"Log: {log}, Additional Log: {additional_log}")
|
|
@@ -713,25 +723,6 @@ def get_cfg_hash(test):
|
|
|
713
723
|
else:
|
|
714
724
|
return test, module_if_pkt.cfg_hash
|
|
715
725
|
|
|
716
|
-
def module_ack_search(test, test_pkt, mgmt_type, wait=True):
|
|
717
|
-
"""
|
|
718
|
-
module ack search
|
|
719
|
-
wait=False is for pwr mgmt off - in order to send the "off" pkt repeatidly while searching for the ack
|
|
720
|
-
"""
|
|
721
|
-
if wait:
|
|
722
|
-
test, mgmt_pkts = scan_for_mgmt_pkts(test, [mgmt_type])
|
|
723
|
-
else:
|
|
724
|
-
mgmt_pkts = cert_mqtt.get_brg2gw_mgmt_pkts(test.mqttc, test, mgmt_types=[mgmt_type])
|
|
725
|
-
if not test.rc:
|
|
726
|
-
for p in mgmt_pkts:
|
|
727
|
-
pkt = p[MGMT_PKT].pkt
|
|
728
|
-
if (pkt == test_pkt.pkt):
|
|
729
|
-
return test, True
|
|
730
|
-
if wait:
|
|
731
|
-
test.rc = TEST_FAILED
|
|
732
|
-
test.add_reason(f"{mgmt_type} module does not match pkt received")
|
|
733
|
-
print(test.reason)
|
|
734
|
-
return test, False
|
|
735
726
|
|
|
736
727
|
def brg_restore_defaults_check(test):
|
|
737
728
|
print("Starting Restore Defaults Check")
|
|
@@ -777,8 +768,7 @@ def brg_pwr_mgmt_turn_on(test):
|
|
|
777
768
|
brg_mac=test.active_brg.id_int, static_on_duration=30, static_sleep_duration=60,
|
|
778
769
|
dynamic_leds_on=0,dynamic_keep_alive_period=0, dynamic_keep_alive_scan=0,
|
|
779
770
|
dynamic_on_duration=0,dynamic_sleep_duration=0))
|
|
780
|
-
cert_config.
|
|
781
|
-
test = module_ack_search(test, test_pkt=wltpkt, mgmt_type=module)[0]
|
|
771
|
+
test = cert_config.brg_configure(test=test, cfg_pkt=wltpkt, module=module)[0]
|
|
782
772
|
|
|
783
773
|
if test.rc == TEST_FAILED:
|
|
784
774
|
test.add_reason("Turning pwr mgmt ON failed, Didn't receive GW MEL pwr mgmt ON pkt")
|
|
@@ -797,16 +787,15 @@ def brg_pwr_mgmt_turn_off(test):
|
|
|
797
787
|
static_on_duration=0,static_sleep_duration=0,
|
|
798
788
|
dynamic_leds_on=0,dynamic_keep_alive_period=0,
|
|
799
789
|
dynamic_keep_alive_scan=0,dynamic_on_duration=0,dynamic_sleep_duration=0))
|
|
800
|
-
found =
|
|
801
|
-
while
|
|
802
|
-
cert_config.
|
|
803
|
-
test, found = module_ack_search(test, wltpkt, module, wait=False)
|
|
790
|
+
found = NOT_FOUND
|
|
791
|
+
while found != DONE:
|
|
792
|
+
test, found = cert_config.brg_configure(test=test, cfg_pkt=wltpkt, module=module, wait=False)
|
|
804
793
|
if ((datetime.datetime.now() - start_time).seconds > (ag.PWR_MGMT_DEFAULTS_KEEP_ALIVE_PERIOD + 1)):
|
|
805
794
|
test.add_reason(f"Didn't receive GW MEL pwr mgmt OFF ack after {ag.PWR_MGMT_DEFAULTS_KEEP_ALIVE_PERIOD + 1} seconds")
|
|
806
795
|
test.rc = TEST_FAILED
|
|
807
796
|
break
|
|
808
797
|
print_update_wait()
|
|
809
|
-
if found:
|
|
798
|
+
if found == DONE:
|
|
810
799
|
utPrint(f"FOUND off pkt after {(datetime.datetime.now() - start_time)} secs", "GREEN")
|
|
811
800
|
utPrint("SUCCESS! pwr mgmt static mode turned off!", "GREEN")
|
|
812
801
|
return test
|
brg_certificate/cert_config.py
CHANGED
|
@@ -64,7 +64,8 @@ def create_gw_config(test, cfg, version=""):
|
|
|
64
64
|
|
|
65
65
|
def gw_downlink(test, raw_tx_data="", is_ota=False, version="", max_duration=100, max_retries=8):
|
|
66
66
|
pkt = create_gw_downlink_pkt(test, raw_tx_data, is_ota, version=version, max_duration=max_duration, max_retries=max_retries)
|
|
67
|
-
|
|
67
|
+
#TODO: logging print
|
|
68
|
+
# print("GW Downlink:", pkt)
|
|
68
69
|
payload = cert_protobuf.downlink_to_pb(pkt) if test.protobuf else json.dumps(pkt)
|
|
69
70
|
test.mqttc.publish(test.mqttc.update_topic, payload=payload, qos=1)
|
|
70
71
|
|
|
@@ -73,9 +74,9 @@ def create_gw_downlink_pkt(test, raw_tx_data="", is_ota=False, version="", max_d
|
|
|
73
74
|
TX_MAX_DURATION_MS: max_duration,
|
|
74
75
|
TX_MAX_RETRIES: max_retries})
|
|
75
76
|
if is_ota == False:
|
|
76
|
-
ret[ACTION] =
|
|
77
|
+
ret[ACTION] = ACTION_ADVERTISING
|
|
77
78
|
else:
|
|
78
|
-
ret[ACTION] =
|
|
79
|
+
ret[ACTION] = ACTION_BRG_OTA
|
|
79
80
|
ret[GW_ID] = str(test.gw)
|
|
80
81
|
ret[BRIDGE_ID] = test.active_brg.id_str
|
|
81
82
|
ret[IMG_DIR_URL] = f"https://api.us-east-2.prod.wiliot.cloud/v1/bridge/type/{test.active_brg.board_type}/version/{version}/binary/"
|
|
@@ -87,7 +88,7 @@ def create_gw_downlink_pkt(test, raw_tx_data="", is_ota=False, version="", max_d
|
|
|
87
88
|
|
|
88
89
|
def get_default_gw_dict(test=None):
|
|
89
90
|
return dict({WLT_SERVER: test.server if test else PROD, GW_MODE: BLE_WIFI, USE_STAT_LOC: False,
|
|
90
|
-
SERIALIZATION_FORMAT: PROTOBUF})
|
|
91
|
+
SERIALIZATION_FORMAT: PROTOBUF, ACL:dict({ACL_MODE: ACL_DENY , ACL_BRIDGE_IDS:[]})})
|
|
91
92
|
|
|
92
93
|
def config_gw_defaults(test, version=""):
|
|
93
94
|
utPrint(f"Configuring gateway {test.gw} to defaults", "BLUE")
|
|
@@ -262,7 +263,8 @@ def internal_brg_configure(test, cfg_pkt=None, module=None, fields=None, values=
|
|
|
262
263
|
return test, res
|
|
263
264
|
|
|
264
265
|
def send_brg_action(test, action_id, **kwargs):
|
|
265
|
-
|
|
266
|
+
#TODO: logging print
|
|
267
|
+
# print(f"\nSending {ag.ACTIONS_DICT[action_id]}{test.active_brg.api_version} with parameters={kwargs if kwargs else None}")
|
|
266
268
|
test.mqttc.flush_pkts()
|
|
267
269
|
action_pkt = get_default_brg_pkt(test, pkt_type=eval_pkt(f'{ag.ACTIONS_DICT[action_id]}{test.active_brg.api_version}'), **kwargs)
|
|
268
270
|
gw_downlink(test, raw_tx_data=action_pkt.dump())
|
brg_certificate/cert_data_sim.py
CHANGED
|
@@ -144,16 +144,26 @@ class DataSimThread(threading.Thread):
|
|
|
144
144
|
self.delay = delay
|
|
145
145
|
self.pkt_types = pkt_types
|
|
146
146
|
self._stop_event = threading.Event()
|
|
147
|
+
self._pause_event = threading.Event()
|
|
148
|
+
self._pause_event.set()
|
|
147
149
|
self.daemon = True
|
|
148
150
|
|
|
149
151
|
def run(self):
|
|
150
152
|
write_to_data_sim_log_file(f"num_of_pixels={self.num_of_pixels} duplicates={self.duplicates} delay={self.delay} pkt_types={self.pkt_types}\n")
|
|
151
153
|
# Run pixel_sim loop
|
|
152
154
|
while not self._stop_event.is_set():
|
|
155
|
+
self._pause_event.wait()
|
|
153
156
|
for i in range(self.num_of_pixels):
|
|
157
|
+
if self._stop_event.is_set():
|
|
158
|
+
return
|
|
159
|
+
if not self._pause_event.is_set():
|
|
160
|
+
break
|
|
154
161
|
for pkt_type in self.pkt_types:
|
|
162
|
+
if not self._pause_event.is_set():
|
|
163
|
+
break
|
|
155
164
|
pkt = self.pixels[i]
|
|
156
165
|
pkt.set_pkt_type(pkt_type)
|
|
166
|
+
|
|
157
167
|
# Set pkt_id, in Gen3 pkt_type_1 has pkt_id_0+1
|
|
158
168
|
if type(pkt) == WiliotPixelGen3:
|
|
159
169
|
if pkt_type == 1:
|
|
@@ -175,14 +185,26 @@ class DataSimThread(threading.Thread):
|
|
|
175
185
|
TX_MAX_RETRIES: self.duplicates,
|
|
176
186
|
TX_MAX_DURATION_MS: 100,
|
|
177
187
|
ACTION: 0}
|
|
178
|
-
|
|
188
|
+
# Use protobuf if protubuf flag is set to True AND data sim does not use a gw simulator board
|
|
189
|
+
if self.test.protobuf == True and not self.test.gw_sim:
|
|
179
190
|
payload = cert_protobuf.downlink_to_pb(msg)
|
|
180
191
|
else:
|
|
181
192
|
payload = json.dumps(msg)
|
|
182
|
-
self.test.
|
|
193
|
+
self.test.sim_mqttc.publish(self.test.sim_mqttc.update_topic, payload=payload)
|
|
183
194
|
write_to_data_sim_log_file(f"{pkt}" + " {}\n".format(datetime.datetime.now().strftime("%d/%m,%H:%M:%S.%f")[:-4]))
|
|
184
195
|
actual_delay = max(self.delay, self.duplicates*(PIXEL_SIM_MIN_CYCLE))
|
|
185
196
|
time.sleep(actual_delay/1000)
|
|
186
|
-
|
|
187
197
|
def stop(self):
|
|
188
|
-
|
|
198
|
+
"""Stops the thread completely"""
|
|
199
|
+
self._stop_event.set()
|
|
200
|
+
write_to_data_sim_log_file(f"DataSimThread stopped\n")
|
|
201
|
+
|
|
202
|
+
def pause(self):
|
|
203
|
+
"""Pauses the thread execution"""
|
|
204
|
+
self._pause_event.clear()
|
|
205
|
+
write_to_data_sim_log_file(f"DataSimThread paused\n")
|
|
206
|
+
|
|
207
|
+
def resume(self):
|
|
208
|
+
"""Resumes the thread execution"""
|
|
209
|
+
self._pause_event.set()
|
|
210
|
+
write_to_data_sim_log_file(f"DataSimThread resumed\n")
|
brg_certificate/cert_defines.py
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
# Files
|
|
2
2
|
import os
|
|
3
|
+
import importlib.metadata
|
|
3
4
|
# BASE_DIR should be initiated in the same dir as brg_certificate.py
|
|
4
5
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
6
|
+
# CERT_VERSION handling - local/PyPi
|
|
7
|
+
if hasattr(importlib.metadata,'packages_distributions') and "wiliot-certificate" in importlib.metadata.packages_distributions():
|
|
8
|
+
CERT_VERSION = importlib.metadata.version("wiliot-certificate")
|
|
9
|
+
else:
|
|
10
|
+
CERT_VERSION = "local-dev"
|
|
5
11
|
CERT_MQTT_LOG_FILE = "cert_mqtt_log.json"
|
|
6
12
|
DATA_SIM_LOG_FILE = "data_sim_log.txt"
|
|
7
13
|
UT_RESULT_FILE_HTML = "results.html"
|
|
@@ -60,6 +66,15 @@ PROD = "prod"
|
|
|
60
66
|
SERIALIZATION_FORMAT = "serializationFormat"
|
|
61
67
|
PROTOBUF = "Protobuf"
|
|
62
68
|
JSON = "JSON"
|
|
69
|
+
ACL = "accessControlList"
|
|
70
|
+
ACL_MODE = "mode"
|
|
71
|
+
ACL_MODE_ALLOW = "mode_allow"
|
|
72
|
+
ACL_BRIDGE_IDS = "bridgeIds"
|
|
73
|
+
ACL_IDS = "ids"
|
|
74
|
+
ACL_DENY = "deny"
|
|
75
|
+
ACL_ALLOW = "allow"
|
|
76
|
+
ACL_DENY_VALUE = 0
|
|
77
|
+
ACL_ALLOW_VALUE = 1
|
|
63
78
|
|
|
64
79
|
GET_INFO_ACTION = "getGwInfo"
|
|
65
80
|
REBOOT_GW_ACTION = "rebootGw"
|
|
@@ -78,9 +93,12 @@ TX_PKT = "txPacket"
|
|
|
78
93
|
TX_MAX_DURATION_MS = "txMaxDurationMs"
|
|
79
94
|
TX_MAX_RETRIES = "txMaxRetries"
|
|
80
95
|
TRANPARENT_PKT_LEN = 31 * 2
|
|
96
|
+
ACTION_ADVERTISING = 0
|
|
97
|
+
ACTION_BRG_OTA = 1
|
|
81
98
|
|
|
82
99
|
# Simulator defines
|
|
83
100
|
GW_SIM_BLE_MAC_ADDRESS = 'GW_SIM_BLE_MAC_ADDRESS'
|
|
101
|
+
GW_APP_VERSION_HEADER = 'WILIOT_GW_BLE_CHIP_SW_VER'
|
|
84
102
|
GW_SIM_PREFIX = 'SIM'
|
|
85
103
|
DATA_SIMULATION = 'sim'
|
|
86
104
|
DATA_REAL_TAGS = 'tags'
|
|
@@ -135,6 +153,8 @@ NUM_VAL = "numberValue"
|
|
|
135
153
|
GW_STATUS = "gatewayStatus"
|
|
136
154
|
BRG_UPGRADE = "bridgeUpgrade"
|
|
137
155
|
REBOOT_PKT = "rebootPacket"
|
|
156
|
+
CONFIG = "config"
|
|
157
|
+
ACL_VALUE = "aclValue"
|
|
138
158
|
|
|
139
159
|
# Custom broker
|
|
140
160
|
CUSTOM_BROKER_ENABLE = "customBroker"
|
|
@@ -160,6 +180,8 @@ STATUS_CODE = "status" # Protobuf
|
|
|
160
180
|
IMG_DIR_URL = "imageDirUrl"
|
|
161
181
|
UPGRADE_BLSD = "upgradeBlSd"
|
|
162
182
|
VER_UUID_STR = "versionUUID"
|
|
183
|
+
STEP = "step"
|
|
184
|
+
PROGRESS = "progress"
|
|
163
185
|
VER_MAX_LEN = 31
|
|
164
186
|
|
|
165
187
|
# Versions
|
|
@@ -197,6 +219,7 @@ GW_LONGITUDE_DEFAULT = -117.0839
|
|
|
197
219
|
# Set to work with default when versions tests only pass through new api ver
|
|
198
220
|
GW_API_VER_DEFAULT = "201"
|
|
199
221
|
GW_API_VER_OLD = "200"
|
|
222
|
+
GW_API_VER_LATEST = "205"
|
|
200
223
|
BRG_CFG_HAS_LEN = 2
|
|
201
224
|
CLEAR_DATA_PATH_TIMEOUT = 10
|
|
202
225
|
ACTION_LONG_TIMEOUT = 120
|
|
@@ -215,8 +238,8 @@ TEST_FAILED = -1
|
|
|
215
238
|
TEST_SKIPPED = 1
|
|
216
239
|
TEST_INIT = 2
|
|
217
240
|
NO_RESPONSE = "NO_RESPONSE"
|
|
241
|
+
NOT_FOUND = "NOT_FOUND"
|
|
218
242
|
DONE = "DONE"
|
|
219
|
-
TEST_SUCCESS = ":)"
|
|
220
243
|
MGMT_PKT = "mgmt_pkt"
|
|
221
244
|
UNIFIED_PKT = "unified_pkt"
|
|
222
245
|
SIDE_INFO_SENSOR_PKT = "side_info_sensor_pkt"
|
|
@@ -239,10 +262,14 @@ AWS = "aws"
|
|
|
239
262
|
TEST = "test"
|
|
240
263
|
MULTI_BRG_TEST = "multiBridgeTest" # used for multi brg tests
|
|
241
264
|
GW_ONLY_TEST = "gwOnlyTest" # used for gw only tests
|
|
265
|
+
INTERNAL_BRG = "internalBridge"
|
|
266
|
+
PURPOSE = "purpose"
|
|
267
|
+
MANDATORY = "mandatory"
|
|
268
|
+
DOCUMENTATION = "documentation"
|
|
242
269
|
ALL_SUPPORTED_VALUES = "allSupportedValues"
|
|
243
|
-
|
|
270
|
+
PRE_CONFIG = "Pre config"
|
|
244
271
|
TEST_BODY = "Test Body"
|
|
245
|
-
|
|
272
|
+
RESTORE_CONFIG = "Restore config"
|
|
246
273
|
|
|
247
274
|
# test reasons
|
|
248
275
|
NO_PARAMS_GIVEN = "No parameters given!"
|
brg_certificate/cert_gw_sim.py
CHANGED
|
@@ -13,7 +13,6 @@ import brg_certificate.cert_utils as cert_utils
|
|
|
13
13
|
|
|
14
14
|
# Generic Defines
|
|
15
15
|
SERIAL_TIMEOUT = 0.1 # TODO decide about the right value
|
|
16
|
-
GW_APP_VERSION_HEADER = 'WILIOT_GW_BLE_CHIP_SW_VER'
|
|
17
16
|
STOP_ADVERTISING = '!stop_advertising'
|
|
18
17
|
RESET_GW = '!reset'
|
|
19
18
|
DEDUPLICATION_PKTS = '!deduplication_pkts'
|
|
@@ -82,19 +81,20 @@ def prep_gw(args, mqttc, start_time):
|
|
|
82
81
|
gw = args.gw
|
|
83
82
|
protobuf = False
|
|
84
83
|
internal_brg_mac_addr = os.getenv(GW_SIM_BLE_MAC_ADDRESS)
|
|
84
|
+
internal_brg_ble_ver = os.getenv(GW_APP_VERSION_HEADER)
|
|
85
85
|
if not internal_brg_mac_addr:
|
|
86
86
|
cert_utils.handle_error(f"ERROR: Didn't receive {GW_SIM_BLE_MAC_ADDRESS} response!", start_time)
|
|
87
87
|
internal_brg = cert_utils.ut_prep_brg(args, mqttc, start_time, gw, internal_brg_mac_addr, "prod", protobuf)
|
|
88
88
|
if internal_brg.api_version != ag.API_VERSION_LATEST:
|
|
89
89
|
cert_utils.handle_error(f"ERROR: Certificate FW api_version={internal_brg.api_version} instead of api_version={ag.API_VERSION_LATEST}! Please upgrade the FW!", start_time)
|
|
90
|
-
return gw, internal_brg, "prod", {BLE_VERSION:
|
|
90
|
+
return gw, internal_brg, "prod", {BLE_VERSION:internal_brg_ble_ver, WIFI_VERSION:"0.0.0"}, protobuf
|
|
91
91
|
|
|
92
92
|
##############################################
|
|
93
93
|
# UART FUNCTIONS
|
|
94
94
|
##############################################
|
|
95
95
|
def write_to_ble(ble_serial, txt, print_enable=True, sleep=0):
|
|
96
|
-
if print_enable:
|
|
97
|
-
|
|
96
|
+
# if print_enable:
|
|
97
|
+
# print('\n' + txt)
|
|
98
98
|
ble_serial.write(bytes(txt, encoding='utf-8') + b'\r\n')
|
|
99
99
|
if sleep:
|
|
100
100
|
cert_common.wait_time_n_print(sleep)
|
|
@@ -113,9 +113,10 @@ def gw_app_reponse(ble_serial):
|
|
|
113
113
|
input = read_from_ble(ble_serial)
|
|
114
114
|
if GW_APP_VERSION_HEADER in input:
|
|
115
115
|
print(input)
|
|
116
|
-
|
|
116
|
+
ble_chip_sw_ver = re.search(r'WILIOT_GW_BLE_CHIP_SW_VER=(\d+\.\d+\.\d+)', input).group(1)
|
|
117
|
+
ble_mac_address = re.search(r'WILIOT_GW_BLE_CHIP_MAC_ADDRESS=([0-9A-F]{12})', input).group(1)
|
|
117
118
|
print("success!")
|
|
118
|
-
return TEST_PASSED, ble_mac_address
|
|
119
|
+
return TEST_PASSED, ble_mac_address, ble_chip_sw_ver
|
|
119
120
|
print("failure!")
|
|
120
121
|
return TEST_FAILED, ''
|
|
121
122
|
|
|
@@ -192,8 +193,10 @@ def on_unsubscribe(mqttc, userdata, mid):
|
|
|
192
193
|
def on_message(client, userdata, message):
|
|
193
194
|
data = json.loads(message.payload.decode("utf-8"))
|
|
194
195
|
print_enable = True if not PIXEL_SIM_INDICATOR in str(message.payload.decode("utf-8")) else False
|
|
195
|
-
if print_enable:
|
|
196
|
-
|
|
196
|
+
# if print_enable:
|
|
197
|
+
# print("##########\n// Message received at {}, topic={}:\n{}\n".format(datetime.datetime.now().strftime("%d/%m/%Y, %H:%M:%S"), message.topic, str(message.payload.decode("utf-8"))))
|
|
198
|
+
# #TODO: logging print
|
|
199
|
+
# # print("##########\n// Message received at {}, topic={}:\n{}\n".format(datetime.datetime.now().strftime("%d/%m/%Y, %H:%M:%S"), message.topic, str(message.payload.decode("utf-8"))))
|
|
197
200
|
# Send packet to UART
|
|
198
201
|
if TX_PKT in data:
|
|
199
202
|
# Downlink packet
|
|
@@ -264,6 +267,7 @@ def gw_sim_run(port, gw_id, analyze_interference=False):
|
|
|
264
267
|
print("ERROR: didn't get version response!")
|
|
265
268
|
return
|
|
266
269
|
os.environ[GW_SIM_BLE_MAC_ADDRESS] = gw_app_res[1]
|
|
270
|
+
os.environ[GW_APP_VERSION_HEADER] = gw_app_res[2]
|
|
267
271
|
write_to_ble(ble_serial, STOP_ADVERTISING, sleep=2)
|
|
268
272
|
write_to_ble(ble_serial, f"{CONNECTIVITY_STATUS} 1 1")
|
|
269
273
|
|
brg_certificate/cert_mqtt.py
CHANGED
|
@@ -170,6 +170,13 @@ def on_message_protobuf(mqttc, userdata, message):
|
|
|
170
170
|
if pb_decoded is True:
|
|
171
171
|
pb_msg_dict = MessageToDict(pb_msg)
|
|
172
172
|
# Align formats with JSON (bytes to hex strings)
|
|
173
|
+
if 'status' in message.topic:
|
|
174
|
+
if ACTION_STATUS in pb_msg_dict:
|
|
175
|
+
pb_msg_dict[ACTION_STATUS][BRIDGE_ID] = base64.b64decode(pb_msg_dict[ACTION_STATUS][BRIDGE_ID]).hex().upper()
|
|
176
|
+
if GW_STATUS in pb_msg_dict and ACL_IDS in pb_msg_dict[GW_STATUS][CONFIG][ACL][ACL_VALUE]:
|
|
177
|
+
ids_list = pb_msg_dict[GW_STATUS][CONFIG][ACL][ACL_VALUE][ACL_IDS]
|
|
178
|
+
for idx, id in enumerate(ids_list):
|
|
179
|
+
ids_list[idx] = base64.b64decode(id).hex().upper()
|
|
173
180
|
if 'data' in message.topic and PACKETS in pb_msg_dict.keys():
|
|
174
181
|
for idx, pkt in enumerate(pb_msg_dict[PACKETS]):
|
|
175
182
|
pb_msg_dict[PACKETS][idx][PAYLOAD] = base64.b64decode(pkt[PAYLOAD]).hex().upper()
|
|
@@ -353,13 +360,14 @@ def get_brg2gw_mgmt_pkts(mqttc, test=None, mgmt_types=[]):
|
|
|
353
360
|
pkts = [p for p in brg2gw_mgmt_pkts if test.active_brg.id_str in p[PAYLOAD]]
|
|
354
361
|
return pkts
|
|
355
362
|
|
|
356
|
-
def get_unified_data_pkts(test):
|
|
363
|
+
def get_unified_data_pkts(test, only_active_brg=True):
|
|
357
364
|
all_unified_pkts, pkts = [], get_all_sim_data_pkts(test.mqttc) if test.data == DATA_SIMULATION else get_all_data_pkts(test.mqttc)
|
|
358
365
|
for p in pkts:
|
|
359
366
|
if UNIFIED_PKT in p:
|
|
360
367
|
all_unified_pkts += [p]
|
|
361
368
|
pkts = all_unified_pkts
|
|
362
|
-
|
|
369
|
+
if only_active_brg:
|
|
370
|
+
pkts = [p for p in all_unified_pkts if p[ALIAS_BRIDGE_ID] == test.active_brg.id_alias]
|
|
363
371
|
print(f"\nCollected {len(pkts)} unified data pkts")
|
|
364
372
|
return pkts
|
|
365
373
|
|
brg_certificate/cert_prints.py
CHANGED
|
@@ -22,11 +22,13 @@ color = lambda c, t : COLORS["BOLD"]+COLORS[c]+t+COLORS["ENDC"]
|
|
|
22
22
|
pipeline_running = lambda : True if 'BITBUCKET_BUILD_NUMBER' in os.environ else False
|
|
23
23
|
camelcase_to_title = lambda s: ' '.join(word.capitalize() for word in re.split('(?=[A-Z])', s))
|
|
24
24
|
SEP = '\n' + '#'*100 + '\n'
|
|
25
|
-
|
|
26
|
-
__
|
|
27
|
-
\ \
|
|
28
|
-
\
|
|
29
|
-
|
|
25
|
+
WIL_CERT_TEXT = r'''
|
|
26
|
+
__ _____ _ ___ ___ _____ ____ _____ ____ _____ ___ _____ ___ ____ _ _____ _____
|
|
27
|
+
\ \ / /_ _| | |_ _/ _ \_ _| / ___| ____| _ \_ _|_ _| ___|_ _/ ___| / \|_ _| ____|
|
|
28
|
+
\ \ /\ / / | || | | | | | || | | | | _| | |_) || | | || |_ | | | / _ \ | | | _|
|
|
29
|
+
\ V V / | || |___ | | |_| || | | |___| |___| _ < | | | || _| | | |___ / ___ \| | | |___
|
|
30
|
+
\_/\_/ |___|_____|___\___/ |_| \____|_____|_| \_\|_| |___|_| |___\____/_/ \_\_| |_____|
|
|
31
|
+
|
|
30
32
|
'''
|
|
31
33
|
|
|
32
34
|
hex_str2int = lambda s : int(s, 16)
|
brg_certificate/cert_protobuf.py
CHANGED
|
@@ -39,7 +39,7 @@ def gw_cfg_pb(msg: dict):
|
|
|
39
39
|
# Skip GW_MODE since it doesn't exist today and harm the parsing in PB
|
|
40
40
|
if GW_MODE == key:
|
|
41
41
|
continue
|
|
42
|
-
pb_value = wpb.
|
|
42
|
+
pb_value = wpb.GatewayConfigValue()
|
|
43
43
|
if isinstance(val, int):
|
|
44
44
|
pb_value.integerValue = val
|
|
45
45
|
elif isinstance(val, float):
|
|
@@ -48,6 +48,10 @@ def gw_cfg_pb(msg: dict):
|
|
|
48
48
|
pb_value.stringValue = val
|
|
49
49
|
elif isinstance(val, bool):
|
|
50
50
|
pb_value.boolValue = val
|
|
51
|
+
elif isinstance(val, dict) and key == ACL:
|
|
52
|
+
pb_value.aclValue.mode_allow = ACL_DENY_VALUE if msg[ADDITIONAL][ACL][ACL_MODE] == ACL_DENY else ACL_ALLOW_VALUE
|
|
53
|
+
ids_bytes = [bytes.fromhex(id) for id in msg[ADDITIONAL][ACL][ACL_BRIDGE_IDS]]
|
|
54
|
+
pb_value.aclValue.ids.extend(ids_bytes)
|
|
51
55
|
else:
|
|
52
56
|
raise ValueError(f"Unsupported value type for key '{key}': {type(val)}")
|
|
53
57
|
pb_msg.gatewayConfig.config[key].CopyFrom(pb_value)
|