Hi,
The err_code shows NRF_ERROR_INVALID_STATE when called sd_ble_gap_adv_start(). I want to know why it happen, and how to handle it. This happened upon the ble disconnected.
Thanks a lot.
Hi,
If you try to start advertising while you're in a state when it's not allowed to start advertise, then you will get that error code. For instance, if you start advertising while you're in a connection. You can see a explanation of the error codes given by the call in ble_gap.h:
/**@brief Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
*
* @param[in] p_adv_params Pointer to advertising parameters structure.
*
* @return @ref NRF_SUCCESS The BLE stack has started advertising.
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check the accepted ranges and limits.
* @return @ref BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Bluetooth address supplied.
* @return @ref BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST Discoverable mode and whitelist incompatible.
Best regards Håkon