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
4839using namespace utest ::v1;
@@ -64,39 +55,34 @@ static volatile event_t received_event;
6455
6556static 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
7363static 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
8170static 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
8977static 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
9784static 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
206192utest::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