This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52 advertising multiple services

Hi,

Similar questions have already been posted but they don't seem to fit to my problem...

Basically I want to advertise 3 primary services, starting from the 'experimental_ble_app_blinky' example: the already provided lbs service and two new ones. For the moment, the new services are just copy-pasted-renamed from the lbs and are correctly initialized.

I made three modifications:

  • in advertising_init

    ble_uuid_t adv_uuids[] = {{LBS_UUID_SERVICE, m_lbs.uuid_type}, {OWN_UUID_SERVICE, m_own.uuid_type}, {MY_UUID_SERVICE, m_my.uuid_type}};

    advdata.name_type = BLE_ADVDATA_SHORT_NAME;

  • in softdevice_enable_get_default_config

    p_ble_enable_params->common_enable_params.vs_uuid_count = 3;

As RK often suggests, I set a breakpoint at the ble_advdata_set function and got NRF_ERROR_DATA_SIZE. That's good to know, but I haven't any clue to reduce my advertisment data after reducing to short_name and using the scan response (as the example already does). If I correctly understood the functions, it seems that each service uuid is encoded and needs a size of 0x10 for that... what is definetly too large when the maximum size is 0x1F.

Any suggestions about how to advertise 3 services and remain within the advertising size limitations?

Thanks a lot!

Parents
  • Until extended broadcasting data are supported (as per BT 5.0) - and probably even then because you will like to maintain backward compatibility with BT 4.0/4.1/4.2 devices - you need to live with several limitations:

    • There are only 62 bytes available on GAP Broadcaster/Peripheral side.
    • These 62 bytes are divided into Adv. and Scan Resp. data while each cannot exceed 31 bytes (so none of strings can exceed 31 bytes).
    • And to be compliant to BT LE GAP you need to encapsulate all data to valid AD objects which have 2-byte overhead (at least = length and tag/id).

    By simple math you can see that it will be pretty hard to put 3 custom (128-bit = 16-byte) UUIDs there because they should be in one AD object and that would be longer then 31 bytes. You can try to set multiple of "Incomplete List of 128-bit Service Class UUIDs" AD objects and fit 2 such UUIDs there (one to Adv. data and second to Scan Resp. data) but look-up BT SIG Core spec if that is allowed.

Reply
  • Until extended broadcasting data are supported (as per BT 5.0) - and probably even then because you will like to maintain backward compatibility with BT 4.0/4.1/4.2 devices - you need to live with several limitations:

    • There are only 62 bytes available on GAP Broadcaster/Peripheral side.
    • These 62 bytes are divided into Adv. and Scan Resp. data while each cannot exceed 31 bytes (so none of strings can exceed 31 bytes).
    • And to be compliant to BT LE GAP you need to encapsulate all data to valid AD objects which have 2-byte overhead (at least = length and tag/id).

    By simple math you can see that it will be pretty hard to put 3 custom (128-bit = 16-byte) UUIDs there because they should be in one AD object and that would be longer then 31 bytes. You can try to set multiple of "Incomplete List of 128-bit Service Class UUIDs" AD objects and fit 2 such UUIDs there (one to Adv. data and second to Scan Resp. data) but look-up BT SIG Core spec if that is allowed.

Children
Related