# Cannot restart advertising in Beacon example [closed]

asked 2017-04-21 16:46:54 +0200

Hey guys!

I face a problem that I have not been able to solve since several days...

I would like to send only one advertising frame every 4 seconds. I do not want to use connectable mode since I only need to send few values periodically, and I do not need to get any answers. So I have modified "ble beacon example", which appears to be the best starting point for my project.

I have set interval and timeout like this:

#define APP_CFG_NON_CONN_ADV_TIMEOUT    1
#define NON_CONNECTABLE_ADV_INTERVAL    MSEC_TO_UNITS(2000, UNIT_0_625_MS)


Normally I send a frame every 2 seconds, but with the timeout of 1sec, I only send 1 frame and the advertising stops.

I have set a timer every 4 seconds that launches the function "advertising_start()".

It works once. In the main loop, I launch once "avertising_init()" and when the timer reaches 4 seconds, it launches "advertising_start()". However, the next 4 seconds, my board seems to reset. I have enabled nRF_log, and when the timer uses again "advertising_start()" I can see:

APP_ERROR:ERROR:Fatal


Considering this post, I am stopping correctly the advertising. And with this one, it seems that I am restarting it correctly.

I need help to find what I am doing wrong... :D

Thanks for your help!

edit retag reopen delete

### Closed as "the question is answered, right answer was accepted" by F0cks at 2017-04-26 07:28:18 +0200

I don't understand why you are stopping advertising. Just don't set the connectable flag in the advertisment, then it's not connectable and start ble advertising in the softdevice for 4 sec duration. And just let it go. After that it is running as a beacon only with 4 sec between advertisement bursts. No need to mess with it. If you want to alter the advert data on the fly, just modify the struct values that the init routine looks at then run advertising_init and the values get passed over to the softdevice. Again, no need to stop it.

( 2017-04-21 17:36:40 +0200 )editconvert to answer

My problem is not how to send advertising signal every 4 sec but how to stop and restart it... I have power management considerations and I need to stop it. I also know how to change data on the fly and how the non connectable mode is working. Thanks for your answer but it does not help me.

( 2017-04-21 18:30:22 +0200 )editconvert to answer

Hey! That is what I am planning to do: compare which mode consumes more power. To see if there is more or less average power used by spikes when I turn on BLE compared to let it always turn. I have seen your solution in other posts, but I have not tried it because some people say that it has strange behavior. But you have convinced me and for the moment, I do not see any side effect and I do not have "Fatal error" or reset anymore. Thanks a lot for your help!

( 2017-04-24 11:20:59 +0200 )editconvert to answer

Sort by » oldest newest most voted

answered 2017-04-21 20:13:42 +0200

Oh, I get it. I've always used:

                            err_code = sd_ble_gap_adv_stop();
APP_ERROR_CHECK(err_code);


And then:

                            err_code = sd_ble_gap_adv_start(&m_adv_params);
APP_ERROR_CHECK(err_code);


So, far it's worked every time I have used it. Though if you are on a newer SDK, then the API's might have changed. But if they did, Nordic are pretty good at describing the API changes in the release notes.

But from experience, I can tell you that the code executed to stop and start advertising is vastly more power hungry than a few beacons. So you need to be turning it off for quite a while to make it worth it on power consumption.

more

## Recent blog posts

• ### Introducing nRF5 SDK for Mesh

Posted 2017-07-20 09:42:44 by Pär H

Posted 2017-07-19 06:53:42 by Mohammad Afaneh
• ### Unique Thread/Bluetooth multiprotocol solution with nRF5 SDK for Thread and nRF52840 SoC by Nordic

Posted 2017-07-14 10:31:56 by Krzysztof Loska
• ### nRF Connect macros (currently Android only)

Posted 2017-07-14 13:29:14 by Aleksander Nowakowski
• ### Power Optimization — From 3 to 7 Months on a Single Charge

Posted 2017-07-10 14:34:39 by Yaniv Nis

## Recent questions

• ### Purchase CBD Oil From Hemp For Health Impovement

Posted 2017-07-23 19:59:11 by Jina Calhoun
• ### I am in the nrf52-DK board, download S332 SoftDevice v2.0.0 and SDK12.3 in the experimental_ant_bootloader routine, can not enter the DFU mode. How can I operate to enter the Bluetooth DFU state？

Posted 2017-07-23 18:12:06 by bugg
• ### Does "nRF5 SDK for Mesh Alpha 0.9.1" support nRF52840-PDK?

Posted 2017-07-23 16:58:14 by Tao
• ### about baudrate changing

Posted 2017-07-23 15:53:02 by Jim
• ### ble central connect a peripheral with passkey

Posted 2017-07-23 15:14:56 by jimmy

## Stats

Asked: 2017-04-21 16:46:54 +0200

Seen: 53 times

Last updated: Apr 21