when i use the ble_adverting_start(BLE_ADV_MODE_FAST); and then use the ble _advering_start(BLE_ADV_MODE_IDLE); then ble_adverting_start(BLE_ADV_MODE_FAST); the return err_code is 8; then APP_ERROR_CHECK(err_code) it can system abnormal。
when i use the ble_adverting_start(BLE_ADV_MODE_FAST); and then use the ble _advering_start(BLE_ADV_MODE_IDLE); then ble_adverting_start(BLE_ADV_MODE_FAST); the return err_code is 8; then APP_ERROR_CHECK(err_code) it can system abnormal。
Error 8 is defined in nrf_error.h as:
#define NRF_ERROR_INVALID_STATE (NRF_ERROR_BASE_NUM + 8) ///< Invalid state, operation disallowed in this state
If you look at the declaration of the function ble_advertising_start() in ble_advertising.h you will see that it will return this error "if the module is not initialized". So then the question is: have you initialized the ble_advertising module with ble_advertising_init()? If so, can you try to step through the advertising functions with your debugger and see exactly where the error comes from?
Did you ever find a solution to this? I am getting the same thing doing the same order of operations.
Everything has been initialized properly and it works for the first advertising. I get it failing inside the call sd_ble_gap_adv_set_configure() inside ble_advertising_start() with the NRF_ERROR_INVALID_STATE error code. The documentation here, https://www.nordicsemi.com/DocLib/Content/SoftDevice_API_Doc/S132/v6-0-0/group_ble_gap_functions?650#ga9969047f4e7485c3f856c841978cc31a, says for that error code:
Invalid state to perform operation.
Since there isn't a ble_advertising_stop() function, I thought ble_advertising_start() with the mode to BLE_ADV_MODE_IDLE would stop it so the "while advertising" condition for this error shouldn't happen, but I guess I am wrong.
I need my device to turn on and turn off based on certain conditions and I am wondering how the SDK for this softdevice (132 V6.0.0) was meant to be used to accomplish this. I thought I would just turn advertising on for enabled (on) and disconnect and turn advertising to idle for disabled (off) but maybe I should be disabling and enabling the whole softdevice every time? I had issues re-enabling the softdevice when I did try the latter.
Any quick suggestions would be appreciated. Thanks.