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

Discovery DIS

Hello,

I use nrf52840-dk as central_hr and nrf52833-dk as peripheral_hr, examples from NRF Connect SDK.

It works well, but I want to implement reading Device Information like Model Number String on my central device.

I can read it on my phone, using nRF Connect, so peripheral device is ok

So, what I did:

1. Added CONFIG_BT_GATT_DM=y to prj.conf to use Discovery manager

2.Added CONFIG_HEAP_MEM_POOL_SIZE=2048 to prj.conf, because Discovery manager uses k_malloc

3.I call 

err = bt_gatt_dm_start(conn, BT_UUID_DIS, &discovery_cb, NULL);

when connected, and I get into discovery_completed_cb, but I don't understand how to check if Model Number String or Manufacturer Number String exists,

how to check could I read it, write or notify and how to read the value.

Comparing to central_bas example, they use functions like bt_bas_notify_supported(&bas),

and they have special structure for BAS 

static struct bt_bas_client bas;

I didn't find something like this for DIS.

Thank you,

Anton

Parents
  • Hi anSolo, 
    I haven't tried on my own to discover and read DIS characteristic, but you can refer to the bt_bas_handles_assign to do something similar. 

    So you need to make a similar function and instead of assign the BAS service , you call 
    if (bt_uuid_cmp(gatt_service->uuid, BT_UUID_DIS)) {

    After that you need to look for the characteristics inside the DIS service, for BAS it's handled in bt_bas_handles_assign()

    So instead of bt_gatt_dm_char_by_uuid(dm, BT_UUID_BAS_BATTERY_LEVEL); you can call bt_gatt_dm_char_by_uuid(dm, BT_UUID_DIS_MODEL_NUMBER); After that you need to get the characteristic handle using bt_gatt_dm_desc_by_uuid()

    After you get the characteristic handle, you can do a read of the characteristic using bt_gatt_read(). Note that the DIS service doesn't support notification, so unlike the BAS service, you don't enable notification, you do a read instead. 

Reply
  • Hi anSolo, 
    I haven't tried on my own to discover and read DIS characteristic, but you can refer to the bt_bas_handles_assign to do something similar. 

    So you need to make a similar function and instead of assign the BAS service , you call 
    if (bt_uuid_cmp(gatt_service->uuid, BT_UUID_DIS)) {

    After that you need to look for the characteristics inside the DIS service, for BAS it's handled in bt_bas_handles_assign()

    So instead of bt_gatt_dm_char_by_uuid(dm, BT_UUID_BAS_BATTERY_LEVEL); you can call bt_gatt_dm_char_by_uuid(dm, BT_UUID_DIS_MODEL_NUMBER); After that you need to get the characteristic handle using bt_gatt_dm_desc_by_uuid()

    After you get the characteristic handle, you can do a read of the characteristic using bt_gatt_read(). Note that the DIS service doesn't support notification, so unlike the BAS service, you don't enable notification, you do a read instead. 

Children
Related