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

How to find 128 bit uuid services with sd_ble_gattc_primary_services_discover

I am using the heart_rate_collector example code as a base of understanding of the Nordic stack. I have a device I am trying to connect to and the primary service I want to use is marked as an unknown service with a 128 bit uuid. It is the fourth service in the list when I connect to the device with the nordic phone app.

I figured out that passing a NULL to the last parameter of sd_ble_gattc_primary_service_discover tells it to report all services for the device (at least I think so). The BLE_GATTC_EVT_PRIM_SRVC_DESC_RSP event report 3 services and indeed the uuids match the uuids of the first 3 services. They are all known uuid values.

I also noticed the event returned after the sd_ble_gattc_characteristics_discover call also returns 3 characteristics available although there are 5. I did some trying and found out that I can change the value to the start_handle and it will start higher in the sequence and return the other characteristics.

Is there a maximum number of values can be returned at a time and it is 3?

I tried changing the start handle argument to sd_ble_gattc_primary_services_discover from 1 to 2 and now it returns 2 services with the first one missing. So the limit of 3 does not seem to be the answer.

How do I get it to discover the 128bit uuid service?

Thanks in advance for any help,

Johnnie

Parents
  • Hi Johnnie,

    Is the "unknown" service UUID is known to the central in other words, the central knows which 128 bit UUID it's looking for ? Or it's a generic central and the peripheral's proprietary 128 bit UUID (s) are not known in advance to the central ?

    If it's known for the central, the central should add the UUID base into the base UUID data base using sd_ble_uuid_vs_add (so there is a uuid_type bound to that UUID)

    By doing that, you won't receive BLE_UUID_TYPE_UNKNOWN when receiving BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP or BLE_GATTC_EVT_CHAR_DISC_RSP.

    If you don't know in advance, then you have to accept BLE_UUID_TYPE_UNKNOWN then after that do a read with sd_ble_gattc_read() on the start handle received on that event. Then you will have the 128 bit UUID returned as the value of that handle.

    After that you can add the UUID to get the uuid_type for that UUID if you want.

    Note that by spec sd_ble_gattc_primary_service_discover() won't return all the UUID, it's only return the next (can be more than one) primary service. The client expected to call that again with Starting handle set to one greater than the last end handle. Check section 4.4.1 Vol 3 Part G in the Bluetooth Spec v4.2

    I suggest to have a look at our ble_db_discovery.c library.

Reply
  • Hi Johnnie,

    Is the "unknown" service UUID is known to the central in other words, the central knows which 128 bit UUID it's looking for ? Or it's a generic central and the peripheral's proprietary 128 bit UUID (s) are not known in advance to the central ?

    If it's known for the central, the central should add the UUID base into the base UUID data base using sd_ble_uuid_vs_add (so there is a uuid_type bound to that UUID)

    By doing that, you won't receive BLE_UUID_TYPE_UNKNOWN when receiving BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP or BLE_GATTC_EVT_CHAR_DISC_RSP.

    If you don't know in advance, then you have to accept BLE_UUID_TYPE_UNKNOWN then after that do a read with sd_ble_gattc_read() on the start handle received on that event. Then you will have the 128 bit UUID returned as the value of that handle.

    After that you can add the UUID to get the uuid_type for that UUID if you want.

    Note that by spec sd_ble_gattc_primary_service_discover() won't return all the UUID, it's only return the next (can be more than one) primary service. The client expected to call that again with Starting handle set to one greater than the last end handle. Check section 4.4.1 Vol 3 Part G in the Bluetooth Spec v4.2

    I suggest to have a look at our ble_db_discovery.c library.

Children
No Data
Related