Skip to content

Commit 40cd330

Browse files
authored
Merge pull request #14195 from jeromecoutant/PR_LORA_BARE
LoraRadio test update for baremetal support
2 parents 5e1d138 + dd60268 commit 40cd330

File tree

6 files changed

+19
-48
lines changed

6 files changed

+19
-48
lines changed

TESTS/configs/baremetal.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"storage_tdb_external",
2020
"fat_chan",
2121
"lora",
22+
"sx1276-lora-driver",
2223
"nfc",
2324
"network-emac",
2425
"flashiap-block-device",

connectivity/drivers/lora/COMPONENT_SX126X/mbed_lib.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
22
"name": "SX126X-lora-driver",
33
"config": {
4-
"radio": {
5-
"value": "SX126X",
6-
"macro_name" : "MBED_CONF_LORA_RADIO"
7-
},
84
"spi-frequency": {
95
"help": "SPI frequency, Default: 16 MHz",
106
"value": 16000000

connectivity/drivers/lora/COMPONENT_SX1272/mbed_lib.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
22
"name": "sx1272-lora-driver",
33
"config": {
4-
"radio": {
5-
"value": "SX1272",
6-
"macro_name" : "MBED_CONF_LORA_RADIO"
7-
},
84
"spi-frequency": {
95
"help": "SPI frequency, Default: 8 MHz",
106
"value": 8000000

connectivity/drivers/lora/COMPONENT_SX1276/mbed_lib.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
22
"name": "sx1276-lora-driver",
33
"config": {
4-
"radio": {
5-
"value": "SX1276",
6-
"macro_name" : "MBED_CONF_LORA_RADIO"
7-
},
84
"spi-frequency": {
95
"help": "SPI frequency, Default: 8 MHz",
106
"value": 8000000

connectivity/lorawan/mbed_lib.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
"help": "LoRa PHY region: EU868, AS923, AU915, CN470, CN779, EU433, IN865, KR920, US915",
66
"value": "EU868"
77
},
8-
"radio": {
9-
"help": "value set in radio driver : SX126X, SX1272, SX1276"
10-
},
118
"over-the-air-activation": {
129
"help": "When set to 1 the application uses the Over-the-Air activation procedure, default: true",
1310
"value": true

connectivity/lorawan/tests/TESTS/lorawan/loraradio/main.cpp

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,26 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
#if !defined(MBED_CONF_RTOS_PRESENT)
18-
#error [NOT_SUPPORTED] LORADIO test cases require a RTOS to run.
19-
#else
2017

2118
#include "utest.h"
2219
#include "unity.h"
2320
#include "greentea-client/test_env.h"
2421

2522
#include "Semaphore.h"
26-
#include "ThisThread.h"
2723

2824
#include "mbed_trace.h"
2925
#define TRACE_GROUP "RTST"
3026

3127
#include "LoRaRadio.h"
3228

33-
#define SX1272 0xFF
34-
#define SX1276 0xEE
35-
36-
#ifndef MBED_CONF_LORA_RADIO
37-
#error [NOT_SUPPORTED] Lora radio is not set
38-
#else
39-
40-
#if (MBED_CONF_LORA_RADIO == SX1272)
29+
#if COMPONENT_SX1272
4130
#include "SX1272_LoRaRadio.h"
42-
#elif (MBED_CONF_LORA_RADIO == SX1276)
31+
#elif COMPONENT_SX1276
4332
#include "SX1276_LoRaRadio.h"
33+
#elif COMPONENT_SX126X
34+
#include "SX126X_LoRaRadio.h"
4435
#else
45-
#error Lora radio is not configured
36+
#error [NOT_SUPPORTED] Lora radio is not configured
4637
#endif
4738

4839
using namespace utest::v1;
@@ -64,39 +55,34 @@ static volatile event_t received_event;
6455

6556
static void tx_done()
6657
{
67-
rtos::ThisThread::sleep_for(2);
6858
TEST_ASSERT_EQUAL(EV_NONE, received_event);
6959
received_event = EV_TX_DONE;
7060
TEST_ASSERT_EQUAL(osOK, event_sem.release());
7161
}
7262

7363
static void tx_timeout()
7464
{
75-
rtos::ThisThread::sleep_for(2);
7665
TEST_ASSERT_EQUAL(EV_NONE, received_event);
7766
received_event = EV_TX_TIMEOUT;
7867
TEST_ASSERT_EQUAL(osOK, event_sem.release());
7968
}
8069

8170
static void rx_done(const uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)
8271
{
83-
rtos::ThisThread::sleep_for(2);
8472
TEST_ASSERT_EQUAL(EV_NONE, received_event);
8573
received_event = EV_RX_DONE;
8674
TEST_ASSERT_EQUAL(osOK, event_sem.release());
8775
}
8876

8977
static void rx_timeout()
9078
{
91-
rtos::ThisThread::sleep_for(2);
9279
TEST_ASSERT_EQUAL(EV_NONE, received_event);
9380
received_event = EV_RX_TIMEOUT;
9481
TEST_ASSERT_EQUAL(osOK, event_sem.release());
9582
}
9683

9784
static void rx_error()
9885
{
99-
rtos::ThisThread::sleep_for(2);
10086
TEST_ASSERT_EQUAL(EV_NONE, received_event);
10187
received_event = EV_RX_ERROR;
10288
TEST_ASSERT_EQUAL(osOK, event_sem.release());
@@ -124,11 +110,11 @@ void test_set_tx_config()
124110

125111
TEST_ASSERT_EQUAL(RF_IDLE, radio->get_status());
126112

127-
radio->set_tx_config(MODEM_LORA, 13, 0,
128-
0, 7,
129-
1, 8,
130-
false, true, false,
131-
0, false, 100);
113+
radio->set_tx_config(MODEM_LORA, 13, 0, // modem, power, fdev,
114+
0, 7, // bandwidth, datarate,
115+
1, 8, // coderate, preamble_len,
116+
false, true, false, // fix_len, crc_on, freq_hop_on,
117+
0, false, 1000); // hop_period, iq_inverted, timeout
132118
radio->send(buffer, sizeof(buffer));
133119

134120
TEST_ASSERT_EQUAL(RF_TX_RUNNING, radio->get_status());
@@ -205,12 +191,12 @@ utest::v1::status_t test_setup(const size_t number_of_cases)
205191

206192
utest::v1::status_t case_setup_handler(const Case *const source, const size_t index_of_case)
207193
{
208-
#if (MBED_CONF_LORA_RADIO == SX1272)
194+
#if COMPONENT_SX1272
209195
radio = new SX1272_LoRaRadio();
210-
211-
#elif (MBED_CONF_LORA_RADIO == SX1276)
196+
#elif COMPONENT_SX1276
212197
radio = new SX1276_LoRaRadio();
213-
198+
#elif COMPONENT_SX126X
199+
radio = new SX126X_LoRaRadio();
214200
#endif
215201

216202
TEST_ASSERT(radio);
@@ -224,12 +210,14 @@ utest::v1::status_t case_teardown_handler(const Case *const source, const size_t
224210
{
225211
radio->sleep();
226212

227-
#if (MBED_CONF_LORA_RADIO == SX1272)
213+
#if COMPONENT_SX1272
228214
delete static_cast<SX1272_LoRaRadio *>(radio);
229215

230-
#elif (MBED_CONF_LORA_RADIO == SX1276)
216+
#elif COMPONENT_SX1276
231217
delete static_cast<SX1276_LoRaRadio *>(radio);
232218

219+
#elif COMPONENT_SX126X
220+
delete static_cast<SX126X_LoRaRadio *>(radio);
233221
#endif
234222
radio = NULL;
235223

@@ -251,6 +239,3 @@ int main()
251239
{
252240
return !Harness::run(specification);
253241
}
254-
255-
#endif // (MBED_CONF_LORA_RADIO)
256-
#endif // !defined(MBED_CONF_RTOS_PRESENT)

0 commit comments

Comments
 (0)