This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to read Value if Service 128bit UUID is completely different from Characteristics 128 bit UUID ?

I am able to pair a peripheral device using advertising 16bit UUID to the Central Device(nRF52840-DK board).

Also I am able to read the Battery level service and Device  information service using bas_c_init() and dis_c_inti(). That' Good.

Now device has Some other Custom Primary services with different 128bit service UUID & 128bit Characteristics UUID. See Image Below 

 

To read such values from Unknown Characteristics which function we need to use ? 

I am using nRF52840-DK with nRF5_SDK_17.0.2 and S140

  • Hi Einar,

    You are right about the debug build instead of release build. Appreciate your help and guidance.

    I was able to reproduce all error above you mentioned. 

    And after correcting all of them it was connecting to the Custom 128bit UUID service and showing DB_DISCOVERY_COMPLETE.

    But  my end goal is to read value of Characteristic which has different 128 bit UUID Base than service 128 bit UUID.

    how we can add different 128bit characteristic UUID. as in ble_lbs_c.h allow us to add only 16 bit characteristic UUID only.

  • Hi, 

    Vipul2988 said:
    how we can add different 128bit characteristic UUID. as in ble_lbs_c.h allow us to add only 16 bit characteristic UUID only.

    In fact, the LBS is also a 128 bit characteristic, so you should do exactly as demonstrated there. The way it works is that you create a base UUID (referred to as uuid_type). So when you make a new base UUID, that is referred to by the type. When you then make a new characteristic and refer to the type of the base UUID, you only provide the extra 2 bytes / 16 bit, that are combined with the base UUID of the type to make the 128 bit UUID.

  • HI Einar,

    When I am trying to connect only service with 128bit UUID it is found and connected.

    But when I am adding another 128bit UUID for Characteristics in ble_lbs_c_init() function, it is not giving any error but also not connecting to service and characteristics.

    Please find attached zip file and open ble_central example. 

     

    nRF5_SDK_15.3.0.zip

  • Hi,

    I did not understand exactly what you meant, can you elaborate?

    In any case I see something which does not look correct. You have two calls to sd_ble_uuid_vs_add() where you try to add two bases. But the ID is output to the same variable (&p_ble_lbs_c->uuid_type), so the first is overwritten. And then cannot be used. Please double check the code so that you avoid suck mistakes.

    (Another detail I see is that you ignore the return value of the fist call to sd_ble_uuid_vs_add(). While it does not fail in this case, ignoring return value is never a good idea and typically prevents you from discovering issues early).

  • HI Einar,

    I means to say whey I am serching services with only 128bit base, it is working good.

    but as and when I tried to add characteristics with diffferent128 bit, I am not getting any output and Error as well.   

    Can you suggest how my ble_lbs_c_init() function should look like ?

    uint32_t ble_lbs_c_init(ble_lbs_c_t * p_ble_lbs_c, ble_lbs_c_init_t * p_ble_lbs_c_init)
    {
        uint32_t      err_code;
    
        ble_uuid_t    lbs_uuid;
        ble_uuid128_t lbs_base_uuid = {PRESS_SER_UUID_BASE};
        ble_uuid_t    lbs_char_uuid;
        ble_uuid128_t lbs_char_base_uuid = {PRESS_CHAR_UUID_BASE};
    
        VERIFY_PARAM_NOT_NULL(p_ble_lbs_c);
        VERIFY_PARAM_NOT_NULL(p_ble_lbs_c_init);
        VERIFY_PARAM_NOT_NULL(p_ble_lbs_c_init->evt_handler);
    
        p_ble_lbs_c->peer_lbs_db.button_cccd_handle = BLE_GATT_HANDLE_INVALID;
        p_ble_lbs_c->peer_lbs_db.button_handle      = BLE_GATT_HANDLE_INVALID;
        p_ble_lbs_c->peer_lbs_db.led_handle         = BLE_GATT_HANDLE_INVALID;
        p_ble_lbs_c->conn_handle                    = BLE_CONN_HANDLE_INVALID;
        p_ble_lbs_c->evt_handler                    = p_ble_lbs_c_init->evt_handler;
    
        err_code = sd_ble_uuid_vs_add(&lbs_base_uuid, &p_ble_lbs_c->uuid_type);
        err_code = sd_ble_uuid_vs_add(&lbs_char_base_uuid, &p_ble_lbs_c->uuid_type);
    
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
        VERIFY_SUCCESS(err_code);
    
       lbs_uuid.type = p_ble_lbs_c->uuid_type;
       lbs_uuid.uuid = LBS_UUID_SERVICE;
    
        //lbs_uuid.type = p_ble_lbs_c->uuid_type;
        //lbs_uuid.uuid = PRESS_SER_UUID;
    
        lbs_char_uuid.type = p_ble_lbs_c->uuid_type;
        lbs_char_uuid.uuid = PRESS_CHAR_UUID;
    
        return ble_db_discovery_evt_register(&lbs_uuid);
        return ble_db_discovery_evt_register(&lbs_char_uuid);
    }

Related