fdsf
Fork of nRF51822 by
Diff: btle/btle.cpp
- Revision:
- 192:3bc89bec110f
- Parent:
- 191:f403e1eb3dd5
- Child:
- 193:29ed6ba3e53f
--- a/btle/btle.cpp Fri Jun 19 15:55:15 2015 +0100 +++ b/btle/btle.cpp Fri Jun 19 15:55:15 2015 +0100 @@ -107,7 +107,6 @@ /* Custom event handler */ switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_CONNECTED: { - printf("received BLE_GAP_EVT_CONNECTED\r\n"); Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle; nRF51Gap::getInstance().setConnectionHandle(handle); const Gap::ConnectionParams_t *params = reinterpret_cast<Gap::ConnectionParams_t *>(&(p_ble_evt->evt.gap_evt.params.connected.conn_params)); @@ -175,6 +174,36 @@ break; } + case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP: + switch (p_ble_evt->evt.gattc_evt.gatt_status) { + case BLE_GATT_STATUS_SUCCESS: { + printf("count of primary services: %u; status code %u\r\n", + p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp.count, p_ble_evt->evt.gattc_evt.gatt_status); + + unsigned index; + for (index = 0; index < p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp.count; index++) { + printf("%x [%u %u]\r\n", + p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp.services[index].uuid.uuid, + p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp.services[index].handle_range.start_handle, + p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp.services[index].handle_range.end_handle); + } + printf("services discover returned %u\r\n", + sd_ble_gattc_primary_services_discover(p_ble_evt->evt.gattc_evt.conn_handle, + p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp.services[index -1].handle_range.end_handle, + NULL)); + break; + } + case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND: { + printf("end of service discovery\r\n"); + break; + } + default: { + printf("gatt failure status: %u\r\n", p_ble_evt->evt.gattc_evt.gatt_status); + break; + } + } + break; + default: break; }