How to discover the all service uuid

Hi!

    In my device,I make a master  to connect a slave,in the NRF5_SDK,all examples for client are initialize with the service uuid.The questions  is when the master don't konw the slave service uuid before connect,how to discover the all slave service uuid?  Just link the android application nRF_Connect,it can discover  all serivce uuid,evnt we don't konw the slave service uuid before connect.

  • Hello,

    You can look at the ble_app_uart_c example. Please note that this application knows the UUID that it is looking for, but the method is the same if you don't know it. 

    You can see that in the ble_evt_handler -> case BLE_GAP_EVT_CONNECTED, it calls ble_db_discovery_start(). This will trigger a series of callbacks in db_disc_handler(). In this example, the only thing that this callback does is to call ble_nus_c_on_db_disc_evt(..., p_evt).  You can see in this function (ble_nus_c_on_db_disc_evt() in ble_nus_c.c) that it only checks whether the p_evt->evt_type is BLE_DB_DISCOVERY_COMPLETE, and then it checks whether the UUID in the DISCOVERY_COMPLETE event is the same as the NUS service UUID. If that returns true, then it checks if the characteristics are the ones that it expects to find.

    So instead of checking whether the UUID is a specific service UUID, you can do whatever you want to do with the UUIDs in this callback (db_disc_handler()).

    Best regards,

    Edvin

Related