This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Service and Characteristic discovery of GATT server on central

I have implemented a Peripheral on an PCA10040 based on one of the SDK (v15) examples. When using nrf Connect with a nRF51 dongle I can connect to the peripheral and interact with my services on the peripherals GATT server.

I now want to do the same thing vice versa, meaning I want to query services on a GATT server on the central from the Peripheral.

So I created a DIS (0x180A) with a manufacturer name sting (0x2A29) and a custom service (0000AABBCCDD11223344556677889900) with one characteristic (0000AABCCCDD11223344556677889900) on the nrf connect application.

During initialization on the NRF52-DK I do:

static void discovery_init(void)
{
    ble_db_discovery_init_t db_init;
    ret_code_t err_code;
    ble_uuid_t uuid;

    memset(&db_init, 0, sizeof(db_init));
    db_init.evt_handler  = discovery_handler;
    db_init.p_gatt_queue = &m_ble_gatt_queue;

    err_code = ble_db_discovery_init(&db_init);
    APP_ERROR_CHECK(err_code);

    uuid.uuid = 0x2A29;  // Manufacturer String
    uuid.type = BLE_UUID_TYPE_BLE;
    err_code = ble_db_discovery_evt_register(&uuid);
    APP_ERROR_CHECK(err_code);

    uuid.uuid = 0xAABC;
    uuid.type = BLE_UUID_TYPE_VENDOR_BEGIN;
    err_code = ble_db_discovery_evt_register(&uuid);
    APP_ERROR_CHECK(err_code);
}

after the connect event BLE_GAP_EVT_CONNECTED I start the discovery:

err_code = ble_db_discovery_start(&m_db_disc, p_ble_evt->evt.gap_evt.conn_handle);
APP_ERROR_CHECK(err_code);

Unfortunately none of the registered services are discovered.

My discovery handler is called three times with the events:

BLE_DB_DISCOVERY_SRV_NOT_FOUND
BLE_DB_DISCOVERY_SRV_NOT_FOUND
BLE_DB_DISCOVERY_AVAILABLE

If I use the 0x180A for the DIS service instead of the characteristic 0x2A29 the handler is called only twice

BLE_DB_DISCOVERY_SRV_NOT_FOUND
BLE_DB_DISCOVERY_AVAILABLE

but I never get a

BLE_DB_DISCOVERY_COMPLETE

What am I missing?

How can I discover custom services?

And can't I just discover all services available on the central and have a look on them somehow?

Thanks for the support.

Related