When BLE_ADV_EXTENDED_ENABLED = true, ble_advertising_start fails.

Hi, it's me, once again. Thankfully the last problem I had was actually my fault... I got distracted and didn't notice a small implementation detail... anyway... Here's today's problem!


I'm trying to enable extended advertising. To do so, I'm just setting `init.config.ble_adv_extended_enabled = true` before calling `ble_advertising_init` (which by the way returns `NRF_SUCCESS`. But when I call `ble_advertising_start`, it fails at the end when it calls the softdevice, `sd_ble_gap_adv_set_configure` with errno = 7 (NRF_ERROR_INVALID_PARAM).


So, what exactly is happening? NRF_ERROR_INVALID_PARAM does not help at all, I mean, the comments at `ble_adv_modes_config_t` don't actually explain anything about what to do when enabling `ble_adv_extended_enabled`, and I didn't find any documentation on it... Automatic docs generated from comments is rarely useful... I've already read what the comment is in the code, I want to know what the flags's effects are and etc... anyway...

All I need to do to make everything work again is set the flag to false... Why does this flag make the softdevice return me `NRF_ERROR_INVALID_PARAM`?

By the way, as I've seen in (https://devzone.nordicsemi.com/f/nordic-q-a/90224/sd_ble_gap_adv_set_configure-returns-nrf_error_invalid_param), it seems that when using `ble_adv_extended_enabled = true`, you must set `flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE.` instead of `BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE`, but that doesn't make any difference to me. Whether it's one flag or the other, if extended mode is *enabled* it doesn't work.

TLDR: if `ble_adv_extended_enabled = true`, I get an errno 7 in this function call at `ble_advertising_start`.

  • Hello,

    I have to agree with you that NRF_ERROR_INVALID_PARAM isn't particularly helpful in this case. sd_ble_gap_adv_set_configure() should almost have had its own error range to cover invalid configurations. Anyway. The reason for the NRF_ERROR_INVALID_PARAM error in this case is that the code attempts to include scan response data when the advertising type is set to nonscannable (Note: the adv. module sets the adv. type to  BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED when you enable .ble_adv_extended_enabled)

    Service UUID included in scan response packet

    Service UUID included in advertisment packet

    Best regards,

    Vidar

  • Thank you! I'll take a look at it and I hope I can give you an answer soon enough.

    Unfortunately I know pretty much zero about bluetooth or the sdk... Don't know what the uuids_complete stuff is for... I must fix this though....

  • Ok, I've removed the service uuid from the scan response packet, and now `ble_advertising_start` returns NRF_SUCCESS. In theory that's nice, but it makes the device disappear in nRF Connect. Is there something else that must be done?

  • The device should still be discoverable after removing the service UUID from the payload. Maybe your central does not support extended scanning?  If you use the android version of nRF connect, please select "Device information" from the app menu. Here you should find a list of supported features on your phone.

    e.g.

    Service UUIDs can optionally be included in the adv. payload to inform observers of available services on your device without requiring them to establish a connection first. It was a bit unclear from my first response, but you will be able to include the UUID if you replace 'srdata' in init.srdata.uuids_complete with 'advdata' like this:

  • Thank you for your answer!

    While waiting, I tried a bunch of stuff. I got the scan response working as well as the main packet. With a little of rethinking about the data that needs to be sent I got it working!

    For some reason I thought I *needed* the UUID for the nordic uart service... but I've just tested it and it's not needed at all, so I'm removing it and then it's more than enough to fit my data.

    My device doesn't support extended advertising! It's a Redmi Note 7 from 2019 which kind of makes me scared? I thought it was recent enough... do you know how widespread is extended advertising capacity in smartphones? Just curious!

    To be as compatible as possible I'm probably going to stick with the main + scan response packet.

    You've been really helpful! Thank you a lot! Also, I've only got to read the guides from the site yesterday and they were very useful as well.

    Best Regargs,
    José Guilherme de C. Rodrigues

Related