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

sd_ble_gap_adv_start

When trying to do a direct advertise massage ( sd_ble_gap_adv_start ) I get error code NRF_ERROR_INVALID_STATE (Invalid state, operation disallowed in this state). This is the configuration:

ble_gap_adv_params_t dir_adv_params; ble_gap_addr_t data;

data.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC; data.addr[0] = xx data.addr[1] = xx data.addr[2] = xx data.addr[3] = xx data.addr[4] = xx data.addr[5] = xx memset(&dir_adv_params, 0, sizeof(dir_adv_params)); dir_adv_params.type = BLE_GAP_ADV_TYPE_ADV_DIRECT_IND; dir_adv_params.p_peer_addr = &data; dir_adv_params.fp = BLE_GAP_ADV_FP_ANY; dir_adv_params.timeout = 0; dir_adv_params.interval = 0; dir_adv_params.p_whitelist = NULL;

sd_ble_gap_adv_start(&dir_adv_params);

There has been a GATT connection just before this and then it is disconnected from the master side. I then on the slave side reconnecting with a direct advertise message.

If I read some threads about this there are some talk about that sd_ble_gap_adv_start will get state error if the connection is not disconnected. But we know that the master side has disconnect the connection. There are also talk about that the file system are busy that could cause this issue. I have been making sure that this is not the case.

I guess that this is an obvious question for some and I think that I do not fully know the correct steps for direct advertise so please guide me in this.

Parents
  • You need to handle the BLE_GAP_EVT_DISCONNECTED event before being able to start advertising. Do you have handling of this event in your BLE event handler? If so, please debug and make sure that it is called before attempting to start advertising.

Reply
  • You need to handle the BLE_GAP_EVT_DISCONNECTED event before being able to start advertising. Do you have handling of this event in your BLE event handler? If so, please debug and make sure that it is called before attempting to start advertising.

Children
No Data
Related