Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDK 15.3.0: Restart Non-Connectable Advertising after Timeout

The objective is to have a device which constantly advertises some status information - this must be always visible to any Central in range.

The device may connect to at most one Central - but must continue to advertise the status information while connected.

So the device has 2 states:

  1. Not connected; doing Connectable advertising;
  2. Connected; doing Non-connectable advertising.

The information in the advertising doesn't change rapidly, so I use the Advertising Timeout as the point to update it; On the timeout event:

  1. Update the advertising data;
  2. Re-start the advertising.

This works fine for Connectable advertising, but not for Non-connectable.

I have tried the solution here, but it doesn't work:

https://devzone.nordicsemi.com/f/nordic-q-a/45644/how-do-i-simply-do-a-non-connectable-advert-on-nrf52-using-sdk-15/187363#187363

I suspect the problem is related to the fiddling with priorities.

So I started again from scratch,

I have attached my modified main.c from the SDK 15.3.0 'Template' example.

Also attached is ble_advertising.c, as I've added some extra logging - but no functional changes.

Here is the trace of a connection:

I get the GAP Connect event, and the Non-connectable advertising starts OK.

But, when the Non-connectable advertising times out:

I get NRF_ERROR_INVALID_PARAM at this point:

This is in non_connectable_advertising_start() - it worked fine to initially start the Non-connectable advertising, so why does it fail on re-starting it?

None of the parameters should have changed!

It is an unhelpful Error code as it give no help in identifying which parameter was invalid, nor how it was invalid. And, because it's an SD call, there's no way to step in to see where it's going wrong.

.

1 2