Reopening this issue from three years ago
as the original question was not answered.
So I had this line of code after sd_softdevice_is_enabled 'returns' false
err_code = nrf_sdh_enable_request(); APP_ERROR_CHECK(err_code);
but the above returned NRF_INVALID_STATE and the application died. I have not been working on this project for a couple of years and I have now updated to the latest SDK and latest Segger Embedded Studio.
So a simple question, why do I get this error when flashing my DK? Doesn't happen on a boot/reset.
If I do this
err_code = nrf_sdh_enable_request(); if (err_code != NRF_ERROR_INVALID_STATE) { APP_ERROR_CHECK(err_code); }
instead my log looks as follows:
<error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at C:\Users\BrianReinhold\projects\nrf52\examples\ble_peripheral\ble_app_met_epoch\main.c:1778 PC at: 0x0002CA5D <error> app: End of error report <debug> app: Power on <debug> app: Main start MET <info> app_timer: RTC: initialized. <debug> app: Initial Epoch time 4086774784 <info> app: Total pages is 256, pg_num is 224 pg_size is 4096 <debug> app: Number of saved stored measurements in flash 0 <error> nrf_sdh_ble: sd_ble_cfg_set() returned NRF_ERROR_INVALID_STATE when attempting to set BLE_CONN_CFG_GAP. <error> nrf_sdh_ble: sd_ble_cfg_set() returned NRF_ERROR_INVALID_STATE when attempting to set BLE_GAP_CFG_ROLE_COUNT. <error> nrf_sdh_ble: sd_ble_cfg_set() returned NRF_ERROR_INVALID_STATE when attempting to set BLE_CONN_CFG_GATT. <error> nrf_sdh_ble: sd_ble_cfg_set() returned NRF_ERROR_INVALID_STATE when attempting to set BLE_COMMON_CFG_VS_UUID. <error> nrf_sdh_ble: sd_ble_cfg_set() returned NRF_ERROR_INVALID_STATE when attempting to set BLE_GATTS_CFG_ATTR_TAB_SIZE. <error> nrf_sdh_ble: sd_ble_cfg_set() returned NRF_ERROR_INVALID_STATE when attempting to set BLE_GATTS_CFG_SERVICE_CHANGED. <debug> app: RAM starts at 0x20002AD8 <info> app: Advertisement is 02 01 06 03 03 90 F9 07 16 90 F9 01 07 10 01 <info> app: Scan response is: 03 19 80 03 07 09 4D 65 74 20 42 50 00 <debug> app: Service initiated <debug> app: char val length 18 <debug> app: Characteristic 0xF991 initiated <debug> app: Characteristic 0xF992 initiated <info> app: MET Start at time 0!
and the app continues to run as it should.
Note that I don't want to initialize if I don't have to. Should I call the disable softdevice method whenever the check returns false or is that just a hack?