able to discover primary services.
parent
7cbfcf8b9b
commit
096071c25e
|
@ -107,7 +107,6 @@ static void btle_handler(ble_evt_t *p_ble_evt)
|
|||
/* 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 @@ static void btle_handler(ble_evt_t *p_ble_evt)
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue