void nRF5xCharacteristicDescriptorDiscoverer::processAttributeInformation( uint16_t connectionHandle, const ble_gattc_evt_attr_info_disc_rsp_t& infos) { Discovery* discovery = findRunningDiscovery(connectionHandle); // the discovery has been removed if(!discovery) { return; } #if (NRF_SD_BLE_API_VERSION <= 2) // for all UUIDS found, process the discovery for (uint16_t i = 0; i < infos.count; ++i) { bool use_16bits_uuids = infos.format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT; const ble_gattc_attr_info_t& attr_info = infos.attr_info[i]; UUID uuid = use_16bits_uuids ? UUID(attr_info.info.uuid16.uuid) : UUID(attr_info.info.uuid128.uuid128, UUID::LSB); discovery->process(attr_info.handle, uuid); } // prepare the next round of descriptors discovery uint16_t startHandle = infos.attr_info[infos.count - 1].handle + 1; #else uint16_t startHandle; // for all UUIDS found, process the discovery if (infos.format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT) { for (uint16_t i = 0; i < infos.count; ++i) { UUID uuid = UUID(infos.info.attr_info16[i].uuid.uuid); discovery->process(infos.info.attr_info16[i].handle, uuid); } // prepare the next round of descriptors discovery startHandle = infos.info.attr_info16[infos.count - 1].handle + 1; } else { for (uint16_t i = 0; i < infos.count; ++i) { UUID uuid = UUID(infos.info.attr_info128[i].uuid.uuid128, UUID::LSB); discovery->process(infos.info.attr_info128[i].handle, uuid); } // prepare the next round of descriptors discovery startHandle = infos.info.attr_info128[infos.count - 1].handle + 1; } #endif uint16_t endHandle = discovery->getCharacteristic().getLastHandle(); if(startHandle > endHandle) { terminate(discovery, BLE_ERROR_NONE); return; } ble_error_t err = gattc_descriptors_discover(connectionHandle, startHandle, endHandle); if(err) { terminate(discovery, err); return; } }
void nRF5xCharacteristicDescriptorDiscoverer::process(uint16_t connectionHandle, const ble_gattc_evt_desc_disc_rsp_t& descriptors) { Discovery* discovery = findRunningDiscovery(connectionHandle); // the discovery has been removed if(!discovery) { return; } for (uint16_t i = 0; i < descriptors.count; ++i) { discovery->process( descriptors.descs[i].handle, UUID(descriptors.descs[i].uuid.uuid) ); } // prepare the next discovery request (if needed) uint16_t startHandle = descriptors.descs[descriptors.count - 1].handle + 1; uint16_t endHandle = discovery->getCharacteristic().getLastHandle(); if(startHandle > endHandle) { terminate(discovery, BLE_ERROR_NONE); return; } ble_error_t err = gattc_descriptors_discover(connectionHandle, startHandle, endHandle); if(err) { terminate(discovery, err); return; } }