Arm Mbed OS support forum

Urgently need to limit BLE Advertising to one channel

Hello

I have an urgent requirement for a covid related project we are working on.

In mbedos 5.11 how do you limit advertising (and scanning if possible) to one channel?

This is the ble advertising construction we are using…

myble.gap().setTxPower(DEFAULT_BEACON_POWER);
myble.gap().setAdvertisingInterval(RET_setting_beacon_interval_ms_active);
myble.gap().updateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA, (uint8_t *)&bleData, sizeof(bleData_t));
myble.gap().startAdvertising();

How do I add parameters to that to limit to channel 37 broadcast?

Thanks

Hi pathfindr,

There is an API for it if non legacy gap is used: https://github.com/ARMmbed/mbed-os/blob/51d55508e8400b60af467005646c4e2164738d48/features/FEATURE_BLE/ble/gap/AdvertisingParameters.h#L230 .

What would be the use case for limiting advertising to a single channel ? It is generally discouraged except for power saving if the battery has to last for several years.

Thanks, is there any way to do it with legacy Gap?

With non legacy gap we see huge increase in power consumption.

And yes we need it to reduce scanning time to save battery.

I’m not sure to follow, advertising on a single channel will likely increase scanning time for central, not reduce it. It saves power on the advertiser at the expense of the scanner that will have to spend more time scanning over the 3 advertising channels to find the device.

AFAIK there is no API to use it with the legacy API.

Does the scanner not always start on the same channel?

The real world is very noisy. Savings in a lab might prove not worth it. The advertising channels are spread out on purpose with a busy environments in mind (2.4 channels nowadays are really busy).

Even if it was the case (AFAIK it isn’t), how would that help ?
The scanner moves from one channel to the others periodically, there’s little guarantee it will start scanning when the advertiser is emitting and it doesn’t wait for it either to listen to another advertising channel.