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

advertise multiple services

Hi,

This seems to be an issue that pops up often. However, I wasn't able to find an answer here in the Nordic forum.

What I have:

  • a number of vendor services
  • (services / characteristics are successfully added, I can see them using a Central device)
  • (I have increased 'vs_uuid_count' as suggested in the forum - works fine)

What I want:

  • From these services I'd like to advertise two
  • (I think I understand how 'ble_advertising_init' works, including advertising data and scan response)
  • (I think I understand the concept behind 'ble_uuid_t' , i.e.byte 12/13 and BLE_UUID_TYPE_VENDOR_BEGIN)

My question:

  • How do I setup advertising so that the 3rd and 5th service is advertised
  • (I understand that I have to use the standard advertisement packet and the scan response to advertise two separate 128bit services)

I appreciate your reply

Thank you Matthias

Parents
  • FormerMember
    0 FormerMember

    Advertising two custom services means to advertise 2 x 16 bytes of data. The maximum payload for advertising data is 31 bytes. It means that two custom services won't fit within the advertising data. What you can do is to add one service UUID in the advertising data, and add the other service UUID in the scan response data.

    Regarding how to add the service UUIDs: In ble_app_uart in the SDK, the struct ble_uuid_t is used to manange UUIDs.

    ble_uuid_t.uuid is byte 12-13 of the advertised UUID.

    ble_uuid.type refers to the base UUID of the service, added using sd_ble_uuid_vs_add(..).

    The base UUID is the 128-bit/16-byte UUID without byte 12-13. It means that when adding a 128-bit UUID using sd_ble_uuid_vs_add(..), byte 12-13 will be discarded (replaced by zeros). When using services and/or characteristics, you have to refer to both the base UUID and byte 12-13 of the UUID in use.

    In ble_app_uart, BLE_UUID_NUS_SERVICE is byte 12-13 and NUS_SERVICE_UUID_TYPE is the base UUID.

Reply Children
No Data
Related