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

Error in "is_UUID_present"

Hi!

I want to connect a nrf51 dk with a beacon and I'm using the UUID to make the connection. In the beacon code I define the UUID in this way:

ble_uuid_t adv_uuids[] = {{BCS_UUID_SERVICE, m_bcs.uuid_type}};
ble_uuid_t m_adv_uuids[]= {BLE_UUID_OUR_SERVICE_UUID,BLE_UUID_TYPE_VENDOR_BEGIN}; //aggiunta da noi
// Build and set advertising data
memset(&advdata, 0, sizeof(advdata));
advdata.name_type               = BLE_ADVDATA_FULL_NAME;
advdata.include_appearance      = true;
advdata.flags.size              = sizeof(flags);
advdata.flags.p_data            = &flags;

memset(&scanrsp, 0, sizeof(scanrsp));
scanrsp.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
scanrsp.uuids_complete.p_uuids  = m_adv_uuids;

err_code = ble_advdata_set(&advdata, &scanrsp);
APP_ERROR_CHECK(err_code);

In the nrf51 I use the function is_UUID_present and I get the error NRF_ERROR_NOT_FOUND (for a 128bit UUID no match in the populated table of UUIDs ) and the code that I use is

else if ( (field_type == BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE)
            || (field_type == BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE)
            )
{
                    
    err_code = sd_ble_uuid_decode(UUID128_SIZE, 
                                  &p_data[index + 2], 
                                  &extracted_uuid);
    if (err_code == NRF_SUCCESS)
    {    
        if ((extracted_uuid.uuid == p_target_uuid->uuid)
            && (extracted_uuid.type == p_target_uuid->type))
        {
               return true;
        }
    }
                    
}

Can someone explain me why this happens? Thank you so much! projects.rar

  • If I paste those lines in ble_nus_c_init I obtain the error NRF_ERROR_NO_MEM from the function sd_ble_uuid_vs_add

  • Try this:

    uint32_t ble_nus_c_init(ble_nus_c_t * p_ble_nus_c, ble_nus_c_init_t * p_ble_nus_c_init)
    {
        uint32_t      err_code;
        ble_uuid_t    uart_uuid;
        ble_uuid128_t nus_base_uuid = {0x23, 0xD1, 0x13, 0xEF, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00}; // <-- Put your 128-bit base UUID;
            
        VERIFY_PARAM_NOT_NULL(p_ble_nus_c);
        VERIFY_PARAM_NOT_NULL(p_ble_nus_c_init);
        
        err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_ble_nus_c->uuid_type);
        VERIFY_SUCCESS(err_code);
        
        uart_uuid.type = p_ble_nus_c->uuid_type;
        uart_uuid.uuid = 0xABCD; // <-- Put your 16-bit service UUID here
    
  • I have done like this:

    uint32_t ble_nus_c_init(ble_nus_c_t * p_ble_nus_c, ble_nus_c_init_t * p_ble_nus_c_init)
    {
        uint32_t      err_code;
        ble_uuid_t    uart_uuid;
        ble_uuid128_t nus_base_uuid = BLE_UUID_OUR_BASE_UUID;
            
        VERIFY_PARAM_NOT_NULL(p_ble_nus_c);
        VERIFY_PARAM_NOT_NULL(p_ble_nus_c_init);
        
        err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_ble_nus_c->uuid_type);
        VERIFY_SUCCESS(err_code);
        
        uart_uuid.type = p_ble_nus_c->uuid_type;
        uart_uuid.uuid = BLE_UUID_OUR_SERVICE_UUID;
    

    and now I have no error from sd_ble_uuid_vs_add but I stil have NRF_ERROR_NOT_FOUND from is_uuid_present

  • See my edit 1 and 2 above.

  • I loaded the code but I had to include our_service.h otherwise it doesn't work.But my beacon and my nrf51 still don't connect to each other

Related