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

  • It looks like it should be something like this (note the comment that you must also update ble_lbs_c_t in this case):

    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);
    
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
        VERIFY_SUCCESS(err_code);
    
        err_code = sd_ble_uuid_vs_add(&lbs_char_base_uuid, &p_ble_lbs_c->uuid_type_char); // You need to add uuid_type_char in the ble_lbs_c_t so that it exists
    
        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_char_uuid.type = p_ble_lbs_c->uuid_type_char;
        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