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

  • FormerMember
    0 FormerMember
    1. The maximum number of services that a central/master will be searching for is defined by BLE_DB_DISCOVERY_MAX_SRV.

    2. For the DB discovery module to search for a set of UUIDs, the UUIDs have to be added to the module using ble_db_discovery_evt_register().

  • I have checked out the pc-ble-driver code which lists the version of software I am using as "SoftDevice s132 API version 3". Neither of these two symbols can be found in the sources ("find . -type f -exec grep DISCOVER {} ; -print" fails to find them).

  • Just to clarify: this question concerns the "pc-ble-driver" found here: github.com/.../pc-ble-driver

  • 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.

  • there are 2 important thing to discover 128bit or vendor specified UUIDs. first we should add the uuid by the sd_ble_uuid_vs_add function to discover them as known 128bit uuid. second is we should track found uuid end service handler value and use next number to start discovery again until reahing to 0xffff value. discovery can be done in several steps. in order to read complete 128bit uuid i'm still working on it i guess we should read data from gat or something.


         int cnt=p_prim_srvc_disc_rsp_evt->count;
    
        uint16_t      ServiceStartHandle = p_prim_srvc_disc_rsp_evt->services[cnt-1].handle_range.end_handle;
    if (cnt> 0 && ServiceStartHandle != 0xffff)
    {
    
    StartDiscovery(ServiceStartHandle + 1);
    Log("Continue Discovery from service handle 0x%04X.....", ServiceStartHandle);
    }
    else
    {
    Log("Discovery Finished ------------------------------");
    }

Related