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

gatt service inquiry

Hi,

In addition to listening the advertiser's and beacon data we also need to offer the master application - which is connected to BLE-module via UART - the possibility to connect to peripheral and get information of available GATT-services. For this we need to be able to inquire service uuids from the connected peripheral.

I've been browsing through the examples but not been able to find out the solution for this. There are samples for listening the defined services, but not one for getting the information of all the available services.

Could anyone please guide me to the correct example, or give me some step-by-step information for building such an application.

Devkit used is nRF52840-DK, SDK revision is nRF5_SDK_16.0.0_98a08e2

Regards, Jukka

Parents
  • Hi Jukka

    In your db_disc_handler function, what events are you calling? If you see the db_disc_handler in I.E. the original ble_app_uart_c example you can see the ble_nus_c_on_db_disc_evt() which handles the discovery correctly. You can see that you have to know the UUIDs and UUID types of services you want to discover. Have you done so in your application?

    Best regards,

    Simon

  • Hello Simon,

    The db_disc_handler() is quite original, only addition is to have debug prints there:

    static void db_disc_handler(ble_db_discovery_evt_t * p_evt)
    {
        if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE)
        {
            printf("BLE_DB_DISCOVERY_COMPLETE: srv_uuid=%u, count=%u\r\n", p_evt->params.discovered_db.srv_uuid.uuid, p_evt->params.discovered_db.char_count);
        }
        else if (p_evt->evt_type == BLE_DB_DISCOVERY_ERROR)
        {
            printf("BLE_DB_DISCOVERY_ERROR: error=%u\r\n", p_evt->params.err_code);
        }
        else if (p_evt->evt_type == BLE_DB_DISCOVERY_AVAILABLE)
        {
            printf("BLE_DB_DISCOVERY_AVAILABLE\r\n");
        }
        else if (p_evt->evt_type == BLE_DB_DISCOVERY_SRV_NOT_FOUND)
        {
            printf("BLE_DB_DISCOVERY_SRV_NOT_FOUND\r\n");
        }
    
        ble_nus_c_on_db_disc_evt(&m_ble_nus_c, p_evt);
    }

    However, does your comment "you have to know the UUIDs and UUID types of services you want to discover" mean that actually one can't discover what services the peripheral has got to offer, but it must asked if the peripheral offers the services that we are expecting?

    BR, Jukka

Reply
  • Hello Simon,

    The db_disc_handler() is quite original, only addition is to have debug prints there:

    static void db_disc_handler(ble_db_discovery_evt_t * p_evt)
    {
        if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE)
        {
            printf("BLE_DB_DISCOVERY_COMPLETE: srv_uuid=%u, count=%u\r\n", p_evt->params.discovered_db.srv_uuid.uuid, p_evt->params.discovered_db.char_count);
        }
        else if (p_evt->evt_type == BLE_DB_DISCOVERY_ERROR)
        {
            printf("BLE_DB_DISCOVERY_ERROR: error=%u\r\n", p_evt->params.err_code);
        }
        else if (p_evt->evt_type == BLE_DB_DISCOVERY_AVAILABLE)
        {
            printf("BLE_DB_DISCOVERY_AVAILABLE\r\n");
        }
        else if (p_evt->evt_type == BLE_DB_DISCOVERY_SRV_NOT_FOUND)
        {
            printf("BLE_DB_DISCOVERY_SRV_NOT_FOUND\r\n");
        }
    
        ble_nus_c_on_db_disc_evt(&m_ble_nus_c, p_evt);
    }

    However, does your comment "you have to know the UUIDs and UUID types of services you want to discover" mean that actually one can't discover what services the peripheral has got to offer, but it must asked if the peripheral offers the services that we are expecting?

    BR, Jukka

Children
No Data
Related