This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

why it returns NRF_ERROR_INVALID_STATE when calling sd_ble_gap_adv_start()?

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.

Parents
  • 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

  • The states are triggered by the application, so there's no softdevice-call to figure out which state you're in. Since the softdevice gives you events back for each condition, it's the applications job to know what state it's in.

    BR Håkon

Reply Children
No Data
Related