1# Copyright 2019 Oticon A/S
2# SPDX-License-Identifier: Apache-2.0
3
4from components.basic_commands import le_receiver_test;
5from components.basic_commands import le_transmitter_test;
6from components.basic_commands import le_test_end;
7import time;
8from components.test_spec import TestSpec;
9
10"""
11    Run the command...
12"""
13def LE_Transceiver_Test(transport, trace):
14    trace.trace(3, "Starting le transceiver test");
15
16    RxCh = 0;
17
18    try:
19        le_receiver_test(transport, 0, RxCh, 100);
20        le_transmitter_test(transport, 1, RxCh, 32, 0, 100);
21        transport.wait(3000);
22        RxCount = le_test_end(transport, 0, 100);
23        TxCount = le_test_end(transport, 1, 100);
24    except Exception as e:
25        trace.trace(1, "LE Transceiver Test failed: %s" %str(e));
26        return 1;
27
28    print((RxCount, TxCount));
29
30    success = True if RxCount[0] == 0 and RxCount[1] > 3200 else False;
31    success = success and True if TxCount[0] == 0 and TxCount[1] > 3200 else False;
32    trace.trace(3, "LE Transceiver Test " + ("PASSED" if success else "FAILED") + " with %i device(s)" %transport.n_devices);
33    return 0 if success else -1;
34
35_spec = {};
36_spec["LE_Transceiver_Test"] = \
37    TestSpec(name = "LE Transceiver Test",
38             number_devices = 2,
39             description = "Test that we can execute the LE Transceiver Test.",
40             test_private = LE_Transceiver_Test);
41
42"""
43    Return the test spec which contains info about all the tests
44    this test module provides
45"""
46def get_tests_specs():
47    return _spec;
48
49"""
50    Run a test given its test_spec
51"""
52def run_a_test(args, transport, trace, test_spec):
53    return not test_spec.test_private(transport, trace);
54