I’m testing with ARMmbed/mbed-os-example/BLE_Advertising/source/main.cpp.
Working with Mbed Studio, mbed os 6 and nRF52840 DK.
When the advertising interval is changed to 100ms and _event_queue.call_every() is set to 100ms, it works well. Using the nRF Sniffer, most of advertising interval are seemd nearly 100ms, like this figure.
I was assuming before achieving an advertising interval 100ms, the advertising is stopped and a new advertising start at 25ms. But stopAdvertisng() adn startAdvertising() do not work effectively. The nRF Sniffer shows many of advertising interval are still about 100ms.
Within this example, the advertising interval is defined here:
ble::AdvertisingParameters adv_parameters(
/* you cannot connect to this device, you can only read its advertising data,
* scannable means that the device has extra advertising data that the peer can receive if it
* "scans" it which means it is using active scanning (it sends a scan request) */
ble::advertising_type_t::SCANNABLE_UNDIRECTED,
ble::adv_interval_t(ble::millisecond_t(1000))
);
So if you want to change this to 100ms, or less change here ble::adv_interval_t(ble::millisecond_t(100))
I’m not sure stopping and starting advertising is required here. Usually you start advertising and leave it started as the battery level is updated within this function: _adv_data_builder.setServiceData(GattService::UUID_BATTERY_SERVICE, {&_battery_level, 1});
I understand that the minimum interval for Non-connectable property limited by GAP_ADV_PARAMS_INTERVAL_MIN_NONCON (100ms). I need to set a interval shorter than 100ms, so i’m trying to use stopping and starting.
Ah, maybe this is where the confusion lies… and I wasn’t paying attention. Where did you find GapAdvertisingParams.h? If I search online it directs me to ARMmbed/ble which is out of date. All BLE libraries are already included within the mbedOS/connectivity folder (v6.15)
Yes, that appears to be the case with NON_CONNECTABLE_UNDIRECTED. I’ve never investigated why that option differs from say SCANNABLE_UNDIRECTED, which I tend to use.
Got me puzzled…
EDIT.
So I had to find out… and came across this useful diagram online.