This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Unable to read the 128 bit uuid with base uuid

Hello Team

I need to scan the peripheral dongle's 128 bit UUID service and its characteristics,my code is based on heart rate collector of pc-ble-driver,before scanning I am registering the uuid with the softdevice as per the suggestions from your forum posts as below, its adding and registering but the problem is its displaying the uuid as all 0's as 0x0000000000000000 ,I am also attaching the screenshots

ble_uuid_t    dfu_uuid;
    uint8_t       uuid_type = BLE_UUID_TYPE_VENDOR_BEGIN;
    
    /*Base UUIDs for DFU service characteristics*/
    ble_uuid128_t dfu_base_uuid = 
    {{0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX}
     };


    dfu_uuid.type = BLE_UUID_TYPE_VENDOR_BEGIN;
    dfu_uuid.uuid = BLE_UUID_VALO_SERVICE;

    err_code = sd_ble_uuid_vs_add(m_adapter,&dfu_base_uuid, &uuid_type);
    if(err_code != NRF_SUCCESS)
    {
         printf("custom uuid failed\n");
         fflush(stdout);
    }
    else
    {
        printf("custom uuid added\n");
        fflush(stdout);
    }
     err_code = ble_db_discovery_evt_register(&dfu_uuid);
     if(err_code != NRF_SUCCESS)
    {
         printf("ble_db_discovery_evt_register failed\n");
         fflush(stdout);
    }
    else
    {
        printf("ble_db_discovery_evt_register added\n");
        fflush(stdout);
    }
    // Initiate procedure to find the primary BLE_UUID_MY_SERVICE.
    err_code = sd_ble_gattc_primary_services_discover(m_adapter,
                                                      m_connection_handle, 0x0E,
                                                      &dfu_uuid);
    if (err_code != NRF_SUCCESS)
    {
        printf("Failed to initiate or continue a GATT Primary Service Discovery procedure\n");
        fflush(stdout);
    }
    else
    {
        printf("Initiated or continue a GATT Primary Service Discovery procedure\n");
        fflush(stdout);
    }
    
output:
  • then how should I print my complete 128 bit uuid, how to set the ram so rather than using the 0's need to use my base uuid,Example I want to print the 128 bit from peripheral dongle such as service FAFC00007A059B940E4D9D7C68E5664C and its characteristics FAFC00017A059B940E4D9D7C68E5664C ,FAFC00027A059B940E4D9D7C68E5664C and so on ,but the output is 0x0000000000000000 and 0x0000000000000001 ,is there any way to initialize ram so it can print the actual service uuid and its characteristics, I want to read the actual values my peripheral is advertising 

  • Also the central is adding the UUID base into the base UUID data base using sd_ble_uuid_vs_add
    and registering using ble_db_discovery_evt_register() then how to print the complete 128 bit uuid with base and the service id's and read/write their corresponding values,but first atleast we want to read the data from the peripheral BLE dongle device

  • Hi,

    In the SoftDevice API's you never use the full 128 bit UUID. You set the base, which is then a "type", and you use 16 bit UUID's together with that type. If you want to print the full 128 bit UUID you need to build it yourself. That should not be a problem, though.

    Specifically, when you discover your valo service and print "Discovered valo service..." you use service->uuid.uuid. Remember that this is just octet 12 and 13. But you can also access service->uuid.type, and then you can match that up with the base UUID you configured for that type (which then needs to be a static variable rather than just reside in service_discovery_start() since you need to access it from your on_service_discovery_response() function. Let's say you have something like this close to the top of your main.c:

    static ble_uuid128_t dfu_base_uuid = 
        {{0x4C, 0x66, 0xE5, 0x68, 0x7C, 0x9D, 0x4D, 0x0E, 0x94, 0x9B, 0x05, 0x7A, 0x02, 0xFF, 0xFC, 0xFA}};

    Then you just do the calculation described here to get the 128 bit UUID. But why do you want to do this? If you really want to print this you could also have this hardocded, so that if you get a specific combination of uuid.type and uuid.uuid, you know it is your service and print the hard coded 128 bit UUID.

  • I did not get this question. The printing part was answered in my previous post I believe. If you ask about reading and writing to the characteristics you have discovered, then I suggest referring to an example first and asking specifically if you hare some questions.

  • Hi Einar, My actual question is why its printing all 0's instead of my actual 128 bit uuid of the peripheral device.I want my code to scan the actual uuids from the peripheral device  ,I have referred UART central example from nordic SDK and many examples from your forum and also followed the given procedure to scan the  advertisers corresponding services and characteristics, so I am not sure why its printing o's instead of printing the actual 128 bit UUID from the peripheral

Related