void main_cbsc_tx_run(void) { // Open the ANT channel and initialize the profile module. channel_open(); uint32_t err_code = cbsc_tx_initialize(); APP_ERROR_CHECK(err_code); uint8_t ant_channel; uint8_t event_message_buffer[ANT_EVENT_MSG_BUFFER_MIN_SIZE]; uint8_t event = NO_EVENT; // Extract and process all pending events, while maximizing application sleep. for (;;) { err_code = sd_app_event_wait(); APP_ERROR_CHECK(err_code); // Extract and process all pending ANT stack events. while (sd_ant_event_get(&ant_channel, &event, event_message_buffer) == NRF_SUCCESS) { err_code = cbsc_tx_channel_event_handle(event); APP_ERROR_CHECK(err_code); } } }
/**@brief Function for application main entry. Does not return. */ int main(void) { // ANT event message buffer. static ANT_MESSAGE ant_message_buffer; // Enable SoftDevice. uint32_t err_code; #if defined(S212) || defined(S332) err_code = sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, softdevice_assert_callback, ANT_LICENSE_KEY); #else err_code = sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, softdevice_assert_callback); #endif APP_ERROR_CHECK(err_code); // Set application IRQ to lowest priority. err_code = sd_nvic_SetPriority(SD_EVT_IRQn, NRF_APP_PRIORITY_LOW); APP_ERROR_CHECK(err_code); // Enable application IRQ (triggered from protocol). err_code = sd_nvic_EnableIRQ(SD_EVT_IRQn); APP_ERROR_CHECK(err_code); // Configure ant stack regards used channels. err_code = ant_stack_static_config(); APP_ERROR_CHECK(err_code); // Setup channel ant_channel_tx_broadcast_setup(); uint8_t event; uint8_t ant_channel; // Main loop. for (;;) { // Put CPU in sleep if possible. err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); // Extract and process all pending ANT events as long as there are any left. do { // Fetch the event. err_code = sd_ant_event_get(&ant_channel, &event, ant_message_buffer.aucMessage); if (err_code == NRF_SUCCESS) { // Handle event channel_event_handle(event, &ant_message_buffer); } } while (err_code == NRF_SUCCESS); } }
/**@brief Function for Stride and Distance Monitor RX example main loop. * * @details The main loop will try to sleep as much as possible. Every time a protocol event * occours, the application will be woken up, polling the ANT stack event queue. When finished * processing all events, the application will go back to sleep. */ void sdm_main_loop(void) { uint8_t event_id; uint8_t ant_channel; uint32_t err_code; // ANT event message buffer. static uint8_t event_message_buffer[ANT_EVENT_MSG_BUFFER_MIN_SIZE]; // Main loop. for (;;) { // Put CPU in sleep if possible. err_code = sd_app_event_wait(); APP_ERROR_CHECK(err_code); // Extract and process all pending ANT events as long as there are any left. do { // Fetch the event. err_code = sd_ant_event_get(&ant_channel, &event_id, event_message_buffer); if (err_code == NRF_SUCCESS) { // Handle event. switch (event_id) { case EVENT_RX: err_code = sdm_rx_data_process( &event_message_buffer[ANT_EVENT_BUFFER_INDEX_PAGE_NUM]); APP_ERROR_CHECK(err_code); err_code = sdm_rx_log( event_message_buffer[ANT_EVENT_BUFFER_INDEX_PAGE_NUM]); APP_ERROR_CHECK(err_code); break; case EVENT_RX_FAIL: err_code = sdm_rx_log(SDM_PAGE_EVENT_RX_FAIL); APP_ERROR_CHECK(err_code); break; default: break; } } } while (err_code == NRF_SUCCESS); } }
/**@brief Function to get and handle ant events. */ void poll_for_ant_events(void) { static uint32_t err_code; static uint8_t event; static uint8_t ant_channel; static uint8_t event_message_buffer[MESG_BUFFER_SIZE]; err_code = sd_ant_event_get(&ant_channel, &event, event_message_buffer); if (err_code == NRF_SUCCESS) { if (ant_channel == ASCS_CHANNEL) { led_toggle(POLLED_LED); ascs_handle_ant_event(event, event_message_buffer); } } }
/**@brief Function to get and handle ant events. */ void poll_for_ant_events(void) { static uint32_t err_code; static uint8_t event; static uint8_t ant_channel; static uint8_t event_message_buffer[MESG_BUFFER_SIZE]; err_code = sd_ant_event_get(&ant_channel, &event, event_message_buffer); if (err_code == NRF_SUCCESS) { switch(ant_channel) { case ASCM_CHANNEL: { ascm_handle_ant_event(event, event_message_buffer); break; } case ASCMM_DISCOVERY_CHANNEL: //intentional fallthrough case ASCMM_CHANNEL: { ascmm_handle_ant_event(event, event_message_buffer); break; } case PHONE_CHANNEL: { phc_handle_ant_event(event, event_message_buffer); break; } default: { break; } } } }
void intern_softdevice_events_execute(void) { if (!m_softdevice_enabled) { // SoftDevice not enabled. This can be possible if the SoftDevice was enabled by the // application without using this module's API (i.e softdevice_handler_init) return; } bool no_more_soc_evts = (m_sys_evt_handler == NULL); #ifdef BLE_STACK_SUPPORT_REQD bool no_more_ble_evts = (m_ble_evt_handler == NULL); #endif #ifdef ANT_STACK_SUPPORT_REQD bool no_more_ant_evts = (m_ant_evt_handler == NULL); #endif for (;;) { uint32_t err_code; if (!no_more_soc_evts) { uint32_t evt_id; // Pull event from SOC. #if (defined(BLE_STACK_SUPPORT_REQD) && defined(ANT_STACK_SUPPORT_REQD)) || defined(ANT_STACK_SUPPORT_REQD) // Experimental: The S310 and S210 SoftDevices APIs have a differnt name for the // function to fetch the event. err_code = sd_event_get(&evt_id); #else err_code = sd_evt_get(&evt_id); #endif if (err_code == NRF_ERROR_NOT_FOUND) { no_more_soc_evts = true; } else if (err_code != NRF_SUCCESS) { APP_ERROR_HANDLER(err_code); } else { // Call application's SOC event handler. m_sys_evt_handler(evt_id); } } #ifdef BLE_STACK_SUPPORT_REQD // Fetch BLE Events. if (!no_more_ble_evts) { // Pull event from stack uint16_t evt_len = m_ble_evt_buffer_size; err_code = sd_ble_evt_get(m_evt_buffer, &evt_len); if (err_code == NRF_ERROR_NOT_FOUND) { no_more_ble_evts = true; } else if (err_code != NRF_SUCCESS) { APP_ERROR_HANDLER(err_code); } else { // Call application's BLE stack event handler. m_ble_evt_handler((ble_evt_t *)m_evt_buffer); } } #endif #ifdef ANT_STACK_SUPPORT_REQD // Fetch ANT Events. if (!no_more_ant_evts) { // Pull event from stack err_code = sd_ant_event_get(&((ant_evt_t *)m_evt_buffer)->channel, &((ant_evt_t *)m_evt_buffer)->event, ((ant_evt_t *)m_evt_buffer)->evt_buffer); if (err_code == NRF_ERROR_NOT_FOUND) { no_more_ant_evts = true; } else if (err_code != NRF_SUCCESS) { APP_ERROR_HANDLER(err_code); } else { // Call application's ANT stack event handler. m_ant_evt_handler((ant_evt_t *)m_evt_buffer); } } #endif if (no_more_soc_evts) { // There are no remaining System (SOC) events to be fetched from the SoftDevice. #if defined(ANT_STACK_SUPPORT_REQD) && defined(BLE_STACK_SUPPORT_REQD) // Check if there are any remaining BLE and ANT events. if (no_more_ble_evts && no_more_ant_evts) { break; } #elif defined(BLE_STACK_SUPPORT_REQD) // Check if there are any remaining BLE events. if (no_more_ble_evts) { break; } #elif defined(ANT_STACK_SUPPORT_REQD) // Check if there are any remaining ANT events. if (no_more_ant_evts) { break; } #else // No need to check for BLE or ANT events since there is no support for BLE and ANT // required. break; #endif } } }
/**@brief Function for application main entry, does not return. */ int main(void) { uint32_t err_code; #ifdef TRACE_UART // Configure and make UART ready for usage. const app_uart_comm_params_t comm_params = { RX_PIN_NUMBER, TX_PIN_NUMBER, RTS_PIN_NUMBER, CTS_PIN_NUMBER, APP_UART_FLOW_CONTROL_DISABLED, false, UART_BAUDRATE_BAUDRATE_Baud38400 }; APP_UART_FIFO_INIT(&comm_params, UART_RX_BUF_SIZE, UART_TX_BUF_SIZE, uart_error_handle, APP_IRQ_PRIORITY_LOW, err_code); APP_ERROR_CHECK(err_code); #endif // Initialize timer module. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); // Initialize GPIOTE module. APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS); // Initialize and enable button handler module. static app_button_cfg_t buttons[] = { {BUTTON_0, false, BUTTON_PULL, button_event_handler}, {BUTTON_1, false, BUTTON_PULL, button_event_handler}, }; APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, false); softdevice_setup(); const antfs_params_t params = { ANTFS_CLIENT_SERIAL_NUMBER, ANTFS_CLIENT_DEV_TYPE, ANTFS_CLIENT_MANUF_ID, ANTFS_LINK_FREQ, ANTFS_DEFAULT_BEACON | DATA_AVAILABLE_FLAG_MASK, m_pass_key, m_friendly_name }; antfs_init(¶ms); antfs_channel_setup(); m_pairing_state = PAIRING_OFF; uint8_t event; uint8_t ant_channel; uint8_t event_message_buffer[ANT_EVENT_MSG_BUFFER_MIN_SIZE]; bool allow_sleep; for (;;) { allow_sleep = true; // Process ANT-FS event queue. if (antfs_event_extract(&m_antfs_event)) { antfs_event_process(&m_antfs_event); allow_sleep = false; } // Process ANT event queue. if (sd_ant_event_get(&ant_channel, &event, event_message_buffer) == NRF_SUCCESS) { antfs_message_process(event_message_buffer); allow_sleep = false; } // Process user feedback for pairing authentication request. if (m_pairing_state != PAIRING_OFF) { pairing_user_feedback_handle(); // Reset to default state as been processed. m_pairing_state = PAIRING_OFF; allow_sleep = false; } // Sleep if allowed. if (allow_sleep) { err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); } } }
/**@brief Function for application main entry, does not return. */ int main(void) { uint32_t err_code; // Setup UART. #if defined(TRACE_UART) const app_uart_comm_params_t comm_params = { RX_PIN_NUMBER, TX_PIN_NUMBER, RTS_PIN_NUMBER, CTS_PIN_NUMBER, APP_UART_FLOW_CONTROL_DISABLED, false, UART_BAUDRATE_BAUDRATE_Baud38400 }; APP_UART_FIFO_INIT(&comm_params, UART_RX_BUF_SIZE, UART_TX_BUF_SIZE, uart_error_handle, APP_IRQ_PRIORITY_LOW, err_code); APP_ERROR_CHECK(err_code); #endif err_code = sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, softdevice_assert_callback); APP_ERROR_CHECK(err_code); // Set application IRQ to lowest priority. err_code = sd_nvic_SetPriority(SD_EVT_IRQn, NRF_APP_PRIORITY_LOW); APP_ERROR_CHECK(err_code); // Enable application IRQ (triggered from protocol). err_code = sd_nvic_EnableIRQ(SD_EVT_IRQn); APP_ERROR_CHECK(err_code); // Open HRM RX channel. hrm_rx_open(); uint8_t event; uint8_t ant_channel; uint8_t event_message_buffer[ANT_EVENT_MSG_BUFFER_MIN_SIZE]; printf("Enter hrm rx main processing loop...\n"); // Main loop. for (;;) { err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); // Extract and process all pending ANT events. do { err_code = sd_ant_event_get(&ant_channel, &event, event_message_buffer); if (err_code == NRF_SUCCESS) { if (event == EVENT_RX) { // We are only interested of RX events. hrm_rx_channel_event_handle(event_message_buffer); } } } while (err_code == NRF_SUCCESS); } }
/**@brief Function for application main entry. Does not return. */ int main(void) { // ANT event message buffer. static ant_evt_t ant_event; // Configure LEDs as outputs. nrf_gpio_range_cfg_output(BSP_LED_0, BSP_LED_1); // Set LED_0 and LED_1 high to indicate that the application is running. LEDS_ON(BSP_LED_0_MASK); LEDS_ON(BSP_LED_1_MASK); // Enable SoftDevice. uint32_t err_code; err_code = sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, softdevice_assert_callback); APP_ERROR_CHECK(err_code); // Set application IRQ to lowest priority. err_code = sd_nvic_SetPriority(SD_EVT_IRQn, NRF_APP_PRIORITY_LOW); APP_ERROR_CHECK(err_code); // Enable application IRQ (triggered from protocol). err_code = sd_nvic_EnableIRQ(SD_EVT_IRQn); APP_ERROR_CHECK(err_code); err_code = ant_stack_static_config(); APP_ERROR_CHECK(err_code); // Setup Channel_0 as a TX Master Only. ant_channel_setup(); // Set LED_0 and LED_1 low to indicate that stack is enabled. LEDS_OFF(BSP_LED_0_MASK); LEDS_OFF(BSP_LED_1_MASK); button_init(); // Main loop. for (;;) { // Put CPU in sleep if possible. err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); // Extract and process all pending ANT events as long as there are any left. do { // Fetch the event. err_code = sd_ant_event_get(&ant_event.channel, &ant_event.event, ant_event.evt_buffer); if (err_code == NRF_SUCCESS) { switch(ant_event.channel) { case ANT_RELAY_MASTER_CHANNEL: { ant_process_relay_master(&ant_event); break; } case ANT_RELAY_SLAVE_CHANNEL: { ant_process_relay_slave(&ant_event); break; } case ANT_MOBILE_CHANNEL: { ant_process_mobile(&ant_event); break; } default: { break; } } } } while (err_code == NRF_SUCCESS); } }
void bicycle_power_rx_main_loop_run(void) { uint32_t err_code; // Initialize timer module. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, NULL); // Initialize GPIOTE module. APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS); err_code = bsp_init(BSP_INIT_BUTTONS, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), button_event_handler); APP_ERROR_CHECK(err_code); m_calibration_not_active = true; // Open ANT channel. bicycle_power_channel_open(); bicycle_power_rx_init(); bp_rx_calibration_cb_register(calibration_process_cb_handle); uint8_t ant_channel; uint8_t event_message_buffer[ANT_EVENT_MSG_BUFFER_MIN_SIZE]; uint32_t events; antplus_event_return_t antplus_event; // @note: When it is passed as a parameter to methods, the 32 bit type is used for events // instead of the API defined 8 bit type due to performance reasons. uint32_t event = NO_EVENT; for (;;) { err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); // @note: Use local copy of event flags instead of the original one in order to allow the // compiler more freedom to optimize the code as non-volatile variables do not need // to be fetched from memory before each access. events = m_event_flags; while (events != 0) { // Check for button state event and execute handling if needed. if (events & EVT_BUTTON_0) { m_event_flags &= ~EVT_BUTTON_0; button_press_handle(); } // Check for ANT stack IRQ event and execute handling if needed. if (events & EVT_ANT_STACK) { m_event_flags &= ~EVT_ANT_STACK; while (sd_ant_event_get(&ant_channel, (uint8_t*)&event, event_message_buffer) == NRF_SUCCESS) { if (bp_rx_channel_event_handle(event, event_message_buffer, &antplus_event)) { // We have a pending profile -> application event to be processed. profile_event_handle(&antplus_event); } } } // Check for calibration response timeout event and execute handling if needed. if (events & EVT_CALIBRATION_RESPONSE_TIMEOUT) { m_event_flags &= ~EVT_CALIBRATION_RESPONSE_TIMEOUT; bp_rx_calibration_tout_handle(); } // Take a fresh snapshot of possible new events, which require processing. events = m_event_flags; } } }
/**@brief Function for application main entry. Does not return. */ int main(void) { // ANT event message buffer. static uint8_t event_message_buffer[ANT_EVENT_MSG_BUFFER_MIN_SIZE]; // Configure pins LED0 and LED1 as outputs. nrf_gpio_range_cfg_output(LED_START, LED_STOP); // Set LED0 and LED1 high to indicate that the application is running. NRF_GPIO->OUTSET = (1 << LED0) | (1 << LED1); // Enable SoftDevice. uint32_t err_code; err_code = sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, softdevice_assert_callback); APP_ERROR_CHECK(err_code); // Set application IRQ to lowest priority. err_code = sd_nvic_SetPriority(PROTOCOL_EVENT_IRQn, NRF_APP_PRIORITY_LOW); APP_ERROR_CHECK(err_code); // Enable application IRQ (triggered from protocol). err_code = sd_nvic_EnableIRQ(PROTOCOL_EVENT_IRQn); APP_ERROR_CHECK(err_code); // Setup Channel_0 as a RX Slave. ant_channel_rx_broadcast_setup(); // Set LED0 and LED1 low to indicate that stack is enabled. NRF_GPIO->OUTCLR = (1 << LED0) | (1 << LED1); uint8_t event; uint8_t ant_channel; // Main loop. // Extract events from the stack below when // availabe and process them in the main loop. for (;;) { // Light up LED1 to indicate that CPU is going to sleep nrf_gpio_pin_set(LED1); // Put CPU in sleep if possible err_code = sd_app_event_wait(); APP_ERROR_CHECK(err_code); // Turn off LED on GPIO 9 to indicate that CPU is going out of sleep nrf_gpio_pin_clear(LED1); // Extract and process all pending ANT events as long as there are any left. do { // Fetch the event. err_code = sd_ant_event_get(&ant_channel, &event, event_message_buffer); if (err_code == NRF_SUCCESS) { // Handle event. switch (event) { case EVENT_RX: channel_event_handle(event_message_buffer); break; default: break; } } } while (err_code == NRF_SUCCESS); } }
void intern_softdevice_events_execute(void) { if (!m_softdevice_enabled) { // SoftDevice not enabled. This can be possible if the SoftDevice was enabled by the // application without using this module's API (i.e softdevice_handler_init) return; } #if NRF_MODULE_ENABLED(CLOCK) bool no_more_soc_evts = false; #else bool no_more_soc_evts = (m_sys_evt_handler == NULL); #endif #ifdef BLE_STACK_SUPPORT_REQD bool no_more_ble_evts = (m_ble_evt_handler == NULL); #endif #ifdef ANT_STACK_SUPPORT_REQD bool no_more_ant_evts = (m_ant_evt_handler == NULL); #endif for (;;) { uint32_t err_code; if (!no_more_soc_evts) { if (m_suspended) { // Cancel pulling next event if event handler was suspended by user. return; } uint32_t evt_id; // Pull event from SOC. err_code = sd_evt_get(&evt_id); if (err_code == NRF_ERROR_NOT_FOUND) { no_more_soc_evts = true; } else if (err_code != NRF_SUCCESS) { APP_ERROR_HANDLER(err_code); } else { // Call application's SOC event handler. #if (NRF_MODULE_ENABLED(CLOCK) && defined(SOFTDEVICE_PRESENT)) nrf_drv_clock_on_soc_event(evt_id); if (m_sys_evt_handler) { m_sys_evt_handler(evt_id); } #else m_sys_evt_handler(evt_id); #endif } } #ifdef BLE_STACK_SUPPORT_REQD // Fetch BLE Events. if (!no_more_ble_evts) { if (m_suspended) { // Cancel pulling next event if event handler was suspended by user. return; } // Pull event from stack uint16_t evt_len = m_ble_evt_buffer_size; err_code = sd_ble_evt_get(mp_ble_evt_buffer, &evt_len); if (err_code == NRF_ERROR_NOT_FOUND) { no_more_ble_evts = true; } else if (err_code != NRF_SUCCESS) { APP_ERROR_HANDLER(err_code); } else { // Call application's BLE stack event handler. m_ble_evt_handler((ble_evt_t *)mp_ble_evt_buffer); } } #endif #ifdef ANT_STACK_SUPPORT_REQD // Fetch ANT Events. if (!no_more_ant_evts) { if (m_suspended) { // Cancel pulling next event if event handler was suspended by user. return; } // Pull event from stack err_code = sd_ant_event_get(&m_ant_evt_buffer.channel, &m_ant_evt_buffer.event, m_ant_evt_buffer.msg.evt_buffer); if (err_code == NRF_ERROR_NOT_FOUND) { no_more_ant_evts = true; } else if (err_code != NRF_SUCCESS) { APP_ERROR_HANDLER(err_code); } else { // Call application's ANT stack event handler. m_ant_evt_handler(&m_ant_evt_buffer); } } #endif if (no_more_soc_evts) { // There are no remaining System (SOC) events to be fetched from the SoftDevice. #if defined(ANT_STACK_SUPPORT_REQD) && defined(BLE_STACK_SUPPORT_REQD) // Check if there are any remaining BLE and ANT events. if (no_more_ble_evts && no_more_ant_evts) { break; } #elif defined(BLE_STACK_SUPPORT_REQD) // Check if there are any remaining BLE events. if (no_more_ble_evts) { break; } #elif defined(ANT_STACK_SUPPORT_REQD) // Check if there are any remaining ANT events. if (no_more_ant_evts) { break; } #else // No need to check for BLE or ANT events since there is no support for BLE and ANT // required. break; #endif } } }
/**@brief Function for application main entry. Does not return. */ int main(void) { // ANT event message buffer. static uint8_t event_message_buffer[ANT_EVENT_MSG_BUFFER_MIN_SIZE]; // Enable SoftDevice. uint32_t err_code; err_code = sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, softdevice_assert_callback); APP_ERROR_CHECK(err_code); APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, NULL); err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL); APP_ERROR_CHECK(err_code); // Set application IRQ to lowest priority. err_code = sd_nvic_SetPriority(SD_EVT_IRQn, NRF_APP_PRIORITY_LOW); APP_ERROR_CHECK(err_code); // Enable application IRQ (triggered from protocol). err_code = sd_nvic_EnableIRQ(SD_EVT_IRQn); APP_ERROR_CHECK(err_code); // Setup Channel_0 as a RX Slave. ant_channel_rx_broadcast_setup(); uint8_t event; uint8_t ant_channel; // Main loop. // Extract events from the stack below when // availabe and process them in the main loop. for (;;) { // Use BSP_INDICATE_ALERT_0 to indicate sleep state err_code = bsp_indication_set(BSP_INDICATE_ALERT_0); APP_ERROR_CHECK(err_code); // Put CPU in sleep if possible err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); err_code = bsp_indication_set(BSP_INDICATE_ALERT_OFF); APP_ERROR_CHECK(err_code); // Extract and process all pending ANT events as long as there are any left. do { // Fetch the event. err_code = sd_ant_event_get(&ant_channel, &event, event_message_buffer); if (err_code == NRF_SUCCESS) { // Handle event. switch (event) { case EVENT_RX: channel_event_handle(event_message_buffer); break; default: break; } } } while (err_code == NRF_SUCCESS); } }