Hi,
I'd like to describe an issue i faced during project development.
My setup is: nRF52840 + s140 + sdk15+FreeRtos
When i disable BLE I call:
1) sd_ble_gap_disconnect () . if connected
2) ble_conn_params_stop()
3)nrf_sdh_disable_request();
When I reenable BLE I call:
nrf_sdh_enable_request()
nrf_sdh_ble_enable()
ble_conn_params_init()
....
The problem is that ble_conn_params_init() returns NRF_ERROR_INTERNAL at if initing this way. It caused by call
err_code = app_timer_create(&p_instance->timer_id, APP_TIMER_MODE_SINGLE_SHOT, update_timeout_handler); if (err_code != NRF_SUCCESS) { return NRF_ERROR_INTERNAL; }
For FREERTOS i use app_timer implementation from app_timer_freertos.c
inside it the function
app_timer_create()
has next lines:
if (pinfo->osHandle == NULL) { /* New timer is created */ memset(pinfo, 0, sizeof(app_timer_info_t)); timer_mode = (mode == APP_TIMER_MODE_SINGLE_SHOT) ? pdFALSE : pdTRUE; pinfo->single_shot = (mode == APP_TIMER_MODE_SINGLE_SHOT); pinfo->func = timeout_handler; pinfo->osHandle = xTimerCreate(" ", 1000, timer_mode, pinfo, app_timer_callback); if (pinfo->osHandle == NULL) err_code = NRF_ERROR_NULL; } else { /* Timer cannot be reinitialized using FreeRTOS API */ return NRF_ERROR_INVALID_STATE; }
and else case is executed. The comment explains why I get an error.
/* Timer cannot be reinitialized using FreeRTOS API */
For now I added workaround and skipped error at upper layer but it would be better to get this case fixed in next SDK version.
I suggest adding app_timer_remove() and updating ble_conn_params_stop() might be a good option. Or just skip call
app_timer_create in case if it already created.
Regards,