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

Is it possible to use ble_gattc with S110?

Hi,

I have an nRF51822-based peripheral with S110 softdevice, and it would be handy if I could nose around central's capabilities when it connects my device (I'd like to read out GAP device name, for starters).

The API to make GATTC stuff is present in S110, though when I call functions like sd_ble_gattc_primary_services_discover() I receive BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP with evt->evt.gattc_evt.params.prim_srvc_disc_rsp.count == 0 even though I am quite positive there is at least GAP service exposed in the central.

So, is it possible to read central characteristics with S110, or do I need at least S130 (peripheral+central SD) to do GATTC things?

Thank you.

Parents
  • Hi, during the weekend I've done some additional testing and it seems to me only Windows 10 as a central works for GATTC discovery with S110.

    I've tested following API calls:

    • sd_ble_gattc_primary_services_discover(conn_handle, 0, NULL)
    • sd_ble_gattc_char_value_by_uuid_read(conn_handle, &uuid, &range) with GAP device name UUID
    • sd_ble_gattc_characteristics_discover(conn_handle, &range)

    against following centrals:

    • Android 4.4.2 LG D160 phone, both with and without "nRF Master control panel" application runned, with started GATT server containing heart rate service and standard 1800/1801 - empty data received for all 3 calls
    • Mac mini (late 2012) with OSX ElCapitan- empty data received
    • Lenovo laptop with Linux and latest BlueZ (with -E flag) - empty data received
    • the same laptop with Windows 10 - primary services 1800 and 1801 were present as expected, device name char readout by UUID worked

    Notes:

    • discovery has been made always after bonding
    • in all cases I received correct reply events on each request (BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP, BLE_GATTC_EVT_CHAR_DISC_RSP and BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP), just having no data (except on Win10 where discovery worked as I expected)
    • when I connected LG Android phone (central) to linux laptop (as a peripheral), services 1800/1801 of laptop were visible in nRF Master control panel and laptop's device name characteristic was readable
Reply
  • Hi, during the weekend I've done some additional testing and it seems to me only Windows 10 as a central works for GATTC discovery with S110.

    I've tested following API calls:

    • sd_ble_gattc_primary_services_discover(conn_handle, 0, NULL)
    • sd_ble_gattc_char_value_by_uuid_read(conn_handle, &uuid, &range) with GAP device name UUID
    • sd_ble_gattc_characteristics_discover(conn_handle, &range)

    against following centrals:

    • Android 4.4.2 LG D160 phone, both with and without "nRF Master control panel" application runned, with started GATT server containing heart rate service and standard 1800/1801 - empty data received for all 3 calls
    • Mac mini (late 2012) with OSX ElCapitan- empty data received
    • Lenovo laptop with Linux and latest BlueZ (with -E flag) - empty data received
    • the same laptop with Windows 10 - primary services 1800 and 1801 were present as expected, device name char readout by UUID worked

    Notes:

    • discovery has been made always after bonding
    • in all cases I received correct reply events on each request (BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP, BLE_GATTC_EVT_CHAR_DISC_RSP and BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP), just having no data (except on Win10 where discovery worked as I expected)
    • when I connected LG Android phone (central) to linux laptop (as a peripheral), services 1800/1801 of laptop were visible in nRF Master control panel and laptop's device name characteristic was readable
Children
  • Yes, this depends on the central implementation. So the central need to support service discovery as gatt server as well. I thought android added gatt server implementation in v5.0 (not completely sure though). But I would also test with 6.0 if I where you. If you try iOS it should have multiple services that you can discover.

  • Thanks for your reply. Yesterday I tried discovery against iPhone4S (central) with iOS8.X.X and discovery of primary services returned 0, so again - no luck with that. Weird thing is though, that iOS and AFAIK MacOSX should both expose ANCS services, so I have no idea why I don't see them from S110. I may test it against Android 6.0 on weekend, but I don't give it much chances.

  • Are you sure you are not getting any errors from the softdevice or the peer device? Could you try to change the start handle for sd_ble_gattc_primary_services_discovery to 0x0001 (I would expect using 0 to fail as this is an invalid handle). Both our ANCS example and current time service example are gatt client examples that works with iOS and are able to discover these services. You can also use the nrf sniffer to see if the service discovery / read by group type request is performed.

  • Success! You were absolutely right about the 1-based indexing. Both sd_ble_gattc_primary_services_discover(conn_handle, 1, NULL) and ble_gattc_handle_range_t range = { 1, 0xffff } used in sd_ble_gattc_char_value_by_uuid_read() and sd_ble_gattc_characteristics_discover() must start with index 1 instead of zero. Weird thing that Windows10 are so tolerant about starting index, that it actually worked with zeroes. Anyway, thank you very much!

Related