This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF8001: stop Advertising before connection is made?

I'm working with the nRF8001, at present using the RedBear BLE Shield.

My current issue is that after starting to Advertise, but before a connection is made, I wish to stop advertising and start again with modified local data.

My understanding is that the way to change the data in the advertisement packet is to take the nRF8001 back to Standby mode, set the new data, then begin advertising again.

The obvious way to do this is using the Disconnect command.

What I have tried (among other things!) is invoking lib_aci_disconnect, when no connection has yet been made and there are no current events to be processed. I expect that this should trigger an ACI_EVT_DEVICE_STARTED:ACI_DEVICE_STANDBY event, at which point I can call lib_aci_set_local_data and lib_aci_connect to start it advertising again.

However, what actually happens is that an ACI_EVT_CMD_RSP event is received with cmd_status ACI_STATUS_ERROR_DEVICE_STATE_INVALID.

Looking at the Product Specification document (1.3, i.e. nRF8001_PS_v1.3.pdf), table 31 on page 91 shows that the Disconnect command is available in the Active mode; but the definition of Active mode evidently covers Standby and Advertising as well as Connected (e.g. see figure 45 on page 80 and figure 49 on page 84). However, the entry for Disconnect in table 31 does not have the footnote on the availability X to indicate that it is only sometimes available in that mode (cf ChangeTimingRequest, which has a footnote that it is only available after a ConnectedEvent).

So is Disconnect the way to do this, and if so can you offer any clues as to what I'm doing wrong that prevents it working? Or more generally: how can I stop advertising, before a connection has been made?

Thanks in advance for any light you can shed!

  • ** My current issue is that after starting to Advertise, but before a connection is made, I wish to stop advertising and start again with modified local data.

    **

    You should be able to change the Service Data type in advertising data in the nRF8001 at anypoint before getting connected. Do you really want to stop advertising before you change the advertising data ?

  • Hi David, thanks very much for your answer, I'm a fool...

    For some reason I thought that a lib_aci_set_local_data had to be immediately followed by a lib_aci_connect in order to take effect - and went on a wild good chase to find out how to get back to a situation where lib_aci_connect could be called a second time.

    My problem solved. Thanks!

Related