stop/startAdvertising do not work well for advertising interval to be shorten

Hiroaki_Maezawa
Mon, 23 May 2022 02:51:20 +0000
Mbed OS

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.

Attempting the advertising interval to be shorter than GAP_ADV_PARAMS_INTERVAL_MIN_NONCON (100ms), I modified _event_queue.call_every() handler.

        _event_queue.call_every(
            25ms,
            [this]() {
                update_battery_level();
                _ble.gap().stopAdvertising(ble::LEGACY_ADVERTISING_HANDLE);
                _ble.gap().startAdvertising(ble::LEGACY_ADVERTISING_HANDLE);
            }
        );

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.

Any misunderstanding or mistake are there?
What should I do any more modification?

11 posts - 3 participants