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:
Parents
  • Hi,

    You have two uuid_type variables in your code (dfu_uuid.type and uuid_type). You initialize both to BLE_UUID_TYPE_VENDOR_BEGIN, and pass a pointer to uuid_type when you call sd_ble_uuid_vs_add(). But you do not update dfu_uuid.type with the assigned ID, so this may be wrong. If so, using dfu_uuid going forward will not work if the ID is something other than BLE_UUID_TYPE_VENDOR_BEGIN (in practice only if another UUID type has been added before). Could that be the case here? Can you double-check?

  • If I try to not update the dfu_uuid.type  then I "failed to ailed to initiate or continue a GATT Primary Service Discovery"

    Please check the below code

     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 = 
        {{0x4C0x660xE50x680x7C0x9D0x4D0x0E0x940x9B0x050x7A0x020xFF0xFC0xFA}
         };


        
        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_VALO_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);
        }
    ble_db_discovery_init failed 0
    Discovering primary services
    custom uuid added
    ble_db_discovery_evt_register added
    Failed to initiate or continue a GATT Primary Service Discovery procedure
    Received an un-handled event with ID: 18
    Discovering primary services
    custom uuid added
    ble_db_discovery_evt_register added
    Failed to initiate or continue a GATT Primary Service Discovery procedure
    Received an un-handled event with ID: 18
    Disconnected, reason: 0x08
  • 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

  • Hi,

    Beulah Preethi Vallur said:
    My actual question is why its printing all 0's instead of my actual 128 bit uuid of the peripheral device.

    Yes, I believe I answered that in this post. You are printing mostly invalid memory. the 128 bit UUID does not exist anywhere you can obtain it to print it. If you want it, you have to calculate it yourself, as described in this post.

    Beulah Preethi Vallur said:
    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

    Yes, and from what I can see you have done it correctly (after some adjustments), and it seems to work.

    Beulah Preethi Vallur said:
    I am not sure why its printing o's instead of printing the actual 128 bit UUID from the peripheral

    That is as explained before.

  • Hello Eric,I need to edit the values of my characteristics too like the temperature and other values,Can I be able to read and write the characteristics after discovering the service and its characteristics,can I able to view the values of characteristics before and after modifications?

    Because, just  based on specific combination of  uuid.type and uuid.uuid ,if i just hard code the 128 bit UUID,I also need to modify the existing values in characteristics and able to read the values, how come the nordic nrf Connect app can read and modify the peripheral characteristics,all I am trying is to mimic the nordic nrf Connect desktop application,hope you understood what I am trying to do in my current application. Its not just printing but also read and modify my characteristics 

  • Hi,

    I see. This thread has become quite long though, so I suggest creating a new question for the reading and writing part since the original question about the UUID has been resolved.

Reply Children
Related