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?

Reply
  • 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?

Children
  • Could you please correct my code ,you mean not to update the dfu_uuid.type with the assigned ID(BLE_UUID_TYPE_VENDOR_BEGIN)? Could you please elaborate your answer so I can understand ,thank you so much

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

    Beulah Preethi Vallur said:
    Could you please correct my code ,you mean not to update the dfu_uuid.type with the assigned ID(BLE_UUID_TYPE_VENDOR_BEGIN)? Could you please elaborate your answer so I can understand

    You pass a pointer to one variable (uuid_type) to the call to sd_ble_uuid_vs_add(), and this variable is populated with the ID for this UUID base type by the sd_ble_uuid_vs_add() function (so it is an output). But you do not use this variable further or the data from it, you just use dfu_uuid.type. And since this is not set to the value of uuid_type that may not be correct. This may not be the issue though since it will be BLE_UUID_TYPE_VENDOR_BEGIN  if this is the first to be added. Can you print both and double-check their values? Then you should fix the issue, by passing &dfu_uuid.type instead of &uuid_type to sd_ble_uuid_vs_add()

    Beulah Preethi Vallur said:
    If I try to not update the dfu_uuid.type  then I "failed to ailed to initiate or continue a GATT Primary Service Discovery"

    I see. This suggests that BLE_UUID_TYPE_VENDOR_BEGIN was correct (by luck since this was the first base UUID to be added), so that is likely not the issue.

    Beulah Preethi Vallur said:
    Please check the below code

    With the current changes, the type (dfu_uuid.type) is random (whatever happens to be in memory), since you still pass &uuid_type but don't set dfu_uuid.type. So this will not work. Also, I strongly recomend that you don't just log that there was an error, you should also log the error code for all functions that don't return NRF_SUCCESS to make the logging a lot more useful.

    Can you try to either revert back your code, or do as I suggested, and then post the complete code in a readable way so that I can look at it properly? Either by inserting the files using Insert -> Insert image/video/file or using Insert -> Insert Code.

  • Hello Eric,

    Please find the attached code with printing the error code for all the functions and the values in dfu_uuid.type and uuid.type is '2' (i.e BLE_UUID_TYPE_VENDOR_BEGIN)

    static uint32_t service_discovery_start()
    {
        uint32_t   err_code;
        uint16_t   start_handle = 0x01;
        db_discovery_init();
        
        printf("Discovering primary services\n");
        fflush(stdout);
        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 = 
        {{0x4C, 0x66, 0xE5, 0x68, 0x7C, 0x9D, 0x4D, 0x0E, 0x94, 0x9B, 0x05, 0x7A, 0x02, 0xFF, 0xFC, 0xFA}
         };
    
        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, &dfu_uuid.type);
        if(err_code != NRF_SUCCESS)
        {
             printf("custom uuid failed %d\n",err_code);
             fflush(stdout);
        }
        else
        {
            printf("custom uuid added %d\n",err_code);
            fflush(stdout);
        }
         err_code = ble_db_discovery_evt_register(&dfu_uuid);
         if(err_code != NRF_SUCCESS)
        {
             printf("ble_db_discovery_evt_register failed %d\n",err_code);
             fflush(stdout);
        }
        else
        {
            printf("ble_db_discovery_evt_register added %d\n",err_code);
            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);
        printf("dfu_uuid.type = %d\n and dfu_uuid.uuid = %d\n",dfu_uuid.type,dfu_uuid.uuid);
        fflush(stdout);
        printf("uuid.type = %d\n",uuid_type);
        fflush(stdout);
        if (err_code != NRF_SUCCESS)
        {
            printf("Failed to initiate or continue a GATT Primary Service Discovery procedure %d\n",err_code);
            fflush(stdout);
        }
        else
        {
            printf("Initiated or continue a GATT Primary Service Discovery procedure %d\n",err_code);
            fflush(stdout);
        }
        
        return err_code;
    }

  • Hi,

    This looks better. I see you pass the correct &dfu_uuid.type to sd_ble_uuid_vs_add() now, which is good. Now it is populated with the correct value (you can also delete your uuid_type variable, which is no longer in use, but it is not important).

    From what I can see from your log output there are no errors now (at least in the screenshots). I see the printout with "Discovered valo service" with an all zero UUID, but I don't see any code showing where and how this ins printed, so I cannot say any details about this. Please share the relevant code and logs and describe how they do not match your expectations.

Related