static void rx_error() { wait_ms(2); TEST_ASSERT_EQUAL(EV_NONE, received_event); received_event = EV_RX_ERROR; TEST_ASSERT_EQUAL(osOK, event_sem.release()); }
static void rx_timeout() { wait_ms(2); TEST_ASSERT_EQUAL(EV_NONE, received_event); received_event = EV_RX_TIMEOUT; TEST_ASSERT_EQUAL(osOK, event_sem.release()); }
static void rx_done(const uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) { wait_ms(2); TEST_ASSERT_EQUAL(EV_NONE, received_event); received_event = EV_RX_DONE; TEST_ASSERT_EQUAL(osOK, event_sem.release()); }
static void tx_done() { wait_ms(2); TEST_ASSERT_EQUAL(EV_NONE, received_event); received_event = EV_TX_DONE; TEST_ASSERT_EQUAL(osOK, event_sem.release()); }
static bool fsm_callback(int state, int next_state) { if (next_state == CellularConnectionFSM::STATE_SIM_PIN) { TEST_ASSERT(fsm_semaphore.release() == osOK); return false; } return true; }
static void init_to_sim_state() { cellular.set_serial(&cellular_serial); TEST_ASSERT(cellular.init() == NSAPI_ERROR_OK); #if defined (MDMRTS) && defined (MDMCTS) cellular_serial.set_flow_control(SerialBase::RTSCTS, MDMRTS, MDMCTS); #endif cellular.set_callback(&fsm_callback); TEST_ASSERT(cellular.start_dispatch() == NSAPI_ERROR_OK); cellular_target_state = CellularConnectionFSM::STATE_SIM_PIN; TEST_ASSERT(cellular.continue_to_state(cellular_target_state) == NSAPI_ERROR_OK); TEST_ASSERT(fsm_semaphore.wait(SIM_TIMEOUT) == 1); }
void test_set_tx_config() { uint8_t buffer[] = {0}; TEST_ASSERT_EQUAL(RF_IDLE, radio->get_status()); radio->set_tx_config(MODEM_LORA, 13, 0, 0, 7, 1, 8, false, true, false, 0, false, 100); radio->send(buffer, sizeof(buffer)); TEST_ASSERT_EQUAL(RF_TX_RUNNING, radio->get_status()); TEST_ASSERT_EQUAL(1, event_sem.wait(1000)); TEST_ASSERT_EQUAL(EV_TX_DONE, received_event); received_event = EV_NONE; }
void test_set_rx_config() { TEST_ASSERT_EQUAL(RF_IDLE, radio->get_status()); radio->set_rx_config(MODEM_LORA, 0, // modem, bandwidth, 7, 1, // datarate, coderate, 0, 8, // bandwidth_afc, preamble_len, 24, false, // symb_timeout, fix_len, 0, // payload_len, false, false, 0, // crc_on, freq_hop_on, hop_period, true, false); // iq_inverted, rx_continuous radio->receive(100); TEST_ASSERT_EQUAL(RF_RX_RUNNING, radio->get_status()); TEST_ASSERT_EQUAL(1, event_sem.wait(1000)); // Nobody was sending to us so timeout is expected. TEST_ASSERT_EQUAL(EV_RX_TIMEOUT, received_event); received_event = EV_NONE; }