We are using the Nordic UART service. Our project is based on the example project "ble_app_uart" from version 15.2 of the SDK. I've found after about 3 minutes it stops advertising (the reason why I am unable to connect to it). What would be the most likely cause?
If I connect to it before it stops advertising, it all works fine. I can connect / disconnect again and again with no problems as long as I don't leave it sit advertising for too long. When connecting to it I have been using the central example project (ble_app_uart_c) or an iPad with a custom application. Both give the same behaviour. As far as verifying if it is advertising or not goes, I'm using the nRF Connect Andriod App.
If you take a closer look at the source code, you can see that this is the expected behavior of the ble_app_uart example.
In the example (note that line numbers may differ due to changes you have made); main.c, line:92
#define APP_ADV_DURATION 18000 /**< The advertising duration (180 seconds) in units of 10 milliseconds. */
This define is used in the advertising_init() function: main.c, line:624
init.config.ble_adv_fast_timeout = APP_ADV_DURATION;
This define will stop the advertising if no connection has been initiated after 3 minutes (180 seconds), and the device will go to sleep. If you are using the nRF52-DK, you can wake up the device again by pressing one of the buttons. The DK will then wake up and advertise for the defined duration before going back to sleep again.
You will need to change this in order to advertise for more than 180 seconds. Changing the APP_ADV_DURATION to 0 will make your device advertise indefinitely.
Best regards, Joakim
Setting APP_ADV_DURATION to 0 doesn't seem to work. The function ble_advertising_init() returns 0 (so I guess it was successful). With APP_ADV_DURATION set to zero it doesn't seem to advertise at all.
I've since found in another post that you also need to also change the value of init.advdata.flags.
After making that change it seems to work OK now.
Sorry, I forgot to mention that.
You are correct, thanks for pointing that out!
Best regards, Joakim