Enable and disable BLE adverting to save battery power

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
6 posts / 0 new
Last post
Jitendraprasad
Offline
Last seen:2 years 2 months ago
加入:2017-10-02 10:38
Enable and disable BLE adverting to save battery power

Hello Dialog team,

I am working on Dialog DA14681 "DA1468x_DA15xxx_SDK_1.0.10.1072" SDK. Initially I want to off BLE advertising and when we detect any pin interrupt we need to enable BLE advertising for five minutes of time period and again disable BLE advertising until it's not detect any pin interrupt and so on.
Please let me know the API call for BLE advertising disable and enable.

Any help will be appreciated.

Thanks,
Jitendra

Device:
MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi Jitendrapraprasad,

Hi Jitendrapraprasad,

The device will sleep and wake up depending on either the BLE or RTOS interrupts (if there are interrupts from a BLE event or a Free RTOS timer) or from external wake ups from the wake up module or the VBUS interrupt. So in order to be sleeping with no BLE activity all you have to do is to just prevent any BLE event, so upon booting dont have the device advertise or scan (dont invoke the ble_gap_adv_start() or the corresponding function for scanning) and it will go directly to sleep after 8 seconds. Also in order to wake up via the the wake up timer you will have to configure the module in order to do so, the configuration can be done in the prvSetupHardware() function, you can check the hrp_sensor() in order to see the API's used in order to setup the hw module and how the advertising is initiated when the interrupt occurs.

Thanks MT_dialog

Jitendraprasad
Offline
Last seen:2 years 2 months ago
加入:2017-10-02 10:38
Thanks for the quick answer.

Thanks for the quick answer.

If we not call ble_gap_adv_start() API in boot up time device doesn't advertising. And I can manage the advertising enable on interrupt but after some time I want to disable the advertising.
所以我不能再次禁用广告。Which API used for disable the advertising?

Thanks

IM_Dialog
Offline
Last seen:1 month 3 weeks ago
加入:2016-12-06 22:25
Hi Jitendraprasad

Hi Jitendraprasad

I think the following function is the one you need:

ble_gap_adv_stop()

Best regards

IM_Dialog

Jitendraprasad
Offline
Last seen:2 years 2 months ago
加入:2017-10-02 10:38
Hello

Hello

In my case it looks like "ble_gap_adv_stop()" doesn't seem to functioning.

Here is what I am doing:

1. Initially on system boot up I don't start advertising.
2. I wrote a timer timeout handler in which I am starting advertising using "ble_gap_adv_start(GAP_CONN_MODE_UNDIRECTED)" and I am starting this timer from one of my sensor's ISR routine. (This time is of 100 msec. That means when that ISR gets called after 100 msec of that BLE advertising starts.
3. Once BLE advertising starts in step #2, I am sending the data over BLE for approx 15 sec and the on completion of data sending I am trying to stop BLE advertising using "ble_gap_adv_stop()".

But, after calling "ble_gap_adv_stop()" though BLE advertising doesn't stop. For your reference, I have also tried below sequences:

```
set_advertising_interval(ADV_INTERVAL_FAST);
ble_gap_adv_stop();
```

Could you please guide me whether I am doing anything wrong or am I missing any step?

Thanks

Jitendra

PM_Dialog
Offline
Last seen:1 hour 17 min ago
Staff
加入:2018-02-08 11:03
Hi Jitendraprasad.

Hi Jitendraprasad.

I did a quick example using the ble_adv project, but I am not able to replicate your problem. In my example, I added a software timer (period 10 sec), and up on its expiration, I terminated the advertising by calling the ble_gap_adv_stop function. Please note that if a connection with a peer device has been established the advertising process is terminated, so the ble_gap_adv_stop function has no effect. I am able to understand the (1) and the (2) of your thread, but could you please clarify the (3) step?

Thanks, PM_Dialog