No changes

Fork of nRF51822 by Nordic Semiconductor

Committer:
rgrover1
Date:
Tue Jul 21 13:23:45 2015 +0100
Revision:
393:0f7c5048efb3
Child:
394:95444484329c
Synchronized with git rev c0a8c6b5
Author: Rohit Grover
Merge branch 'master' of https://github.com/adfernandes/nRF51822 into afernandes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 393:0f7c5048efb3 1 /* mbed Microcontroller Library
rgrover1 393:0f7c5048efb3 2 * Copyright (c) 2006-2013 ARM Limited
rgrover1 393:0f7c5048efb3 3 *
rgrover1 393:0f7c5048efb3 4 * Licensed under the Apache License, Version 2.0 (the "License");
rgrover1 393:0f7c5048efb3 5 * you may not use this file except in compliance with the License.
rgrover1 393:0f7c5048efb3 6 * You may obtain a copy of the License at
rgrover1 393:0f7c5048efb3 7 *
rgrover1 393:0f7c5048efb3 8 * http://www.apache.org/licenses/LICENSE-2.0
rgrover1 393:0f7c5048efb3 9 *
rgrover1 393:0f7c5048efb3 10 * Unless required by applicable law or agreed to in writing, software
rgrover1 393:0f7c5048efb3 11 * distributed under the License is distributed on an "AS IS" BASIS,
rgrover1 393:0f7c5048efb3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rgrover1 393:0f7c5048efb3 13 * See the License for the specific language governing permissions and
rgrover1 393:0f7c5048efb3 14 * limitations under the License.
rgrover1 393:0f7c5048efb3 15 */
rgrover1 393:0f7c5048efb3 16
rgrover1 393:0f7c5048efb3 17 #include "nRF5xServiceDiscovery.h"
rgrover1 393:0f7c5048efb3 18
rgrover1 393:0f7c5048efb3 19 ble_error_t
rgrover1 393:0f7c5048efb3 20 nRF5xServiceDiscovery::launchCharacteristicDiscovery(Gap::Handle_t connectionHandle,
rgrover1 393:0f7c5048efb3 21 Gap::Handle_t startHandle,
rgrover1 393:0f7c5048efb3 22 Gap::Handle_t endHandle)
rgrover1 393:0f7c5048efb3 23 {
rgrover1 393:0f7c5048efb3 24 characteristicDiscoveryStarted(connectionHandle);
rgrover1 393:0f7c5048efb3 25
rgrover1 393:0f7c5048efb3 26 ble_gattc_handle_range_t handleRange = {
rgrover1 393:0f7c5048efb3 27 .start_handle = startHandle,
rgrover1 393:0f7c5048efb3 28 .end_handle = endHandle
rgrover1 393:0f7c5048efb3 29 };
rgrover1 393:0f7c5048efb3 30 uint32_t rc;
rgrover1 393:0f7c5048efb3 31 if ((rc = sd_ble_gattc_characteristics_discover(connectionHandle, &handleRange)) != NRF_SUCCESS) {
rgrover1 393:0f7c5048efb3 32 terminateCharacteristicDiscovery();
rgrover1 393:0f7c5048efb3 33 switch (rc) {
rgrover1 393:0f7c5048efb3 34 case BLE_ERROR_INVALID_CONN_HANDLE:
rgrover1 393:0f7c5048efb3 35 case NRF_ERROR_INVALID_ADDR:
rgrover1 393:0f7c5048efb3 36 return BLE_ERROR_INVALID_PARAM;
rgrover1 393:0f7c5048efb3 37 case NRF_ERROR_BUSY:
rgrover1 393:0f7c5048efb3 38 return BLE_STACK_BUSY;
rgrover1 393:0f7c5048efb3 39 default:
rgrover1 393:0f7c5048efb3 40 case NRF_ERROR_INVALID_STATE:
rgrover1 393:0f7c5048efb3 41 return BLE_ERROR_INVALID_STATE;
rgrover1 393:0f7c5048efb3 42 }
rgrover1 393:0f7c5048efb3 43 }
rgrover1 393:0f7c5048efb3 44
rgrover1 393:0f7c5048efb3 45 return BLE_ERROR_NONE;
rgrover1 393:0f7c5048efb3 46 }
rgrover1 393:0f7c5048efb3 47
rgrover1 393:0f7c5048efb3 48 void
rgrover1 393:0f7c5048efb3 49 nRF5xServiceDiscovery::setupDiscoveredServices(const ble_gattc_evt_prim_srvc_disc_rsp_t *response)
rgrover1 393:0f7c5048efb3 50 {
rgrover1 393:0f7c5048efb3 51 serviceIndex = 0;
rgrover1 393:0f7c5048efb3 52 numServices = response->count;
rgrover1 393:0f7c5048efb3 53
rgrover1 393:0f7c5048efb3 54 /* Account for the limitation on the number of discovered services we can handle at a time. */
rgrover1 393:0f7c5048efb3 55 if (numServices > BLE_DB_DISCOVERY_MAX_SRV) {
rgrover1 393:0f7c5048efb3 56 numServices = BLE_DB_DISCOVERY_MAX_SRV;
rgrover1 393:0f7c5048efb3 57 }
rgrover1 393:0f7c5048efb3 58
rgrover1 393:0f7c5048efb3 59 serviceUUIDDiscoveryQueue.reset();
rgrover1 393:0f7c5048efb3 60 for (unsigned serviceIndex = 0; serviceIndex < numServices; serviceIndex++) {
rgrover1 393:0f7c5048efb3 61 if (response->services[serviceIndex].uuid.type == BLE_UUID_TYPE_UNKNOWN) {
rgrover1 393:0f7c5048efb3 62 serviceUUIDDiscoveryQueue.enqueue(serviceIndex);
rgrover1 393:0f7c5048efb3 63 services[serviceIndex].setup(response->services[serviceIndex].handle_range.start_handle,
rgrover1 393:0f7c5048efb3 64 response->services[serviceIndex].handle_range.end_handle);
rgrover1 393:0f7c5048efb3 65 } else {
rgrover1 393:0f7c5048efb3 66 services[serviceIndex].setup(response->services[serviceIndex].uuid.uuid,
rgrover1 393:0f7c5048efb3 67 response->services[serviceIndex].handle_range.start_handle,
rgrover1 393:0f7c5048efb3 68 response->services[serviceIndex].handle_range.end_handle);
rgrover1 393:0f7c5048efb3 69 }
rgrover1 393:0f7c5048efb3 70 }
rgrover1 393:0f7c5048efb3 71
rgrover1 393:0f7c5048efb3 72 /* Trigger discovery of service UUID if necessary. */
rgrover1 393:0f7c5048efb3 73 if (serviceUUIDDiscoveryQueue.getCount()) {
rgrover1 393:0f7c5048efb3 74 serviceUUIDDiscoveryQueue.triggerFirst();
rgrover1 393:0f7c5048efb3 75 }
rgrover1 393:0f7c5048efb3 76 }
rgrover1 393:0f7c5048efb3 77
rgrover1 393:0f7c5048efb3 78 void
rgrover1 393:0f7c5048efb3 79 nRF5xServiceDiscovery::setupDiscoveredCharacteristics(const ble_gattc_evt_char_disc_rsp_t *response)
rgrover1 393:0f7c5048efb3 80 {
rgrover1 393:0f7c5048efb3 81 characteristicIndex = 0;
rgrover1 393:0f7c5048efb3 82 numCharacteristics = response->count;
rgrover1 393:0f7c5048efb3 83
rgrover1 393:0f7c5048efb3 84 /* Account for the limitation on the number of discovered characteristics we can handle at a time. */
rgrover1 393:0f7c5048efb3 85 if (numCharacteristics > BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV) {
rgrover1 393:0f7c5048efb3 86 numCharacteristics = BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV;
rgrover1 393:0f7c5048efb3 87 }
rgrover1 393:0f7c5048efb3 88
rgrover1 393:0f7c5048efb3 89 charUUIDDiscoveryQueue.reset();
rgrover1 393:0f7c5048efb3 90 for (unsigned charIndex = 0; charIndex < numCharacteristics; charIndex++) {
rgrover1 393:0f7c5048efb3 91 if (response->chars[charIndex].uuid.type == BLE_UUID_TYPE_UNKNOWN) {
rgrover1 393:0f7c5048efb3 92 charUUIDDiscoveryQueue.enqueue(charIndex);
rgrover1 393:0f7c5048efb3 93 characteristics[charIndex].setup(gattc,
rgrover1 393:0f7c5048efb3 94 connHandle,
rgrover1 393:0f7c5048efb3 95 response->chars[charIndex].char_props,
rgrover1 393:0f7c5048efb3 96 response->chars[charIndex].handle_decl,
rgrover1 393:0f7c5048efb3 97 response->chars[charIndex].handle_value);
rgrover1 393:0f7c5048efb3 98 } else {
rgrover1 393:0f7c5048efb3 99 characteristics[charIndex].setup(gattc,
rgrover1 393:0f7c5048efb3 100 connHandle,
rgrover1 393:0f7c5048efb3 101 response->chars[charIndex].uuid.uuid,
rgrover1 393:0f7c5048efb3 102 response->chars[charIndex].char_props,
rgrover1 393:0f7c5048efb3 103 response->chars[charIndex].handle_decl,
rgrover1 393:0f7c5048efb3 104 response->chars[charIndex].handle_value);
rgrover1 393:0f7c5048efb3 105 }
rgrover1 393:0f7c5048efb3 106 }
rgrover1 393:0f7c5048efb3 107
rgrover1 393:0f7c5048efb3 108 /* Trigger discovery of char UUID if necessary. */
rgrover1 393:0f7c5048efb3 109 if (charUUIDDiscoveryQueue.getCount()) {
rgrover1 393:0f7c5048efb3 110 charUUIDDiscoveryQueue.triggerFirst();
rgrover1 393:0f7c5048efb3 111 }
rgrover1 393:0f7c5048efb3 112 }
rgrover1 393:0f7c5048efb3 113
rgrover1 393:0f7c5048efb3 114 void
rgrover1 393:0f7c5048efb3 115 nRF5xServiceDiscovery::progressCharacteristicDiscovery(void)
rgrover1 393:0f7c5048efb3 116 {
rgrover1 393:0f7c5048efb3 117 /* Iterate through the previously discovered characteristics cached in characteristics[]. */
rgrover1 393:0f7c5048efb3 118 while ((state == CHARACTERISTIC_DISCOVERY_ACTIVE) && (characteristicIndex < numCharacteristics)) {
rgrover1 393:0f7c5048efb3 119 if ((matchingCharacteristicUUID == UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) ||
rgrover1 393:0f7c5048efb3 120 ((matchingCharacteristicUUID == characteristics[characteristicIndex].getUUID()) &&
rgrover1 393:0f7c5048efb3 121 (matchingServiceUUID != UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)))) {
rgrover1 393:0f7c5048efb3 122 if (characteristicCallback) {
rgrover1 393:0f7c5048efb3 123 characteristicCallback(&characteristics[characteristicIndex]);
rgrover1 393:0f7c5048efb3 124 }
rgrover1 393:0f7c5048efb3 125 }
rgrover1 393:0f7c5048efb3 126
rgrover1 393:0f7c5048efb3 127 characteristicIndex++;
rgrover1 393:0f7c5048efb3 128 }
rgrover1 393:0f7c5048efb3 129
rgrover1 393:0f7c5048efb3 130 /* Relaunch discovery of new characteristics beyond the last entry cached in characteristics[]. */
rgrover1 393:0f7c5048efb3 131 if (state == CHARACTERISTIC_DISCOVERY_ACTIVE) {
rgrover1 393:0f7c5048efb3 132 /* Determine the ending handle of the last cached characteristic. */
rgrover1 393:0f7c5048efb3 133 Gap::Handle_t startHandle = characteristics[characteristicIndex - 1].getValueHandle() + 1;
rgrover1 393:0f7c5048efb3 134 Gap::Handle_t endHandle = services[serviceIndex].getEndHandle();
rgrover1 393:0f7c5048efb3 135 resetDiscoveredCharacteristics(); /* Note: resetDiscoveredCharacteristics() must come after fetching start and end Handles. */
rgrover1 393:0f7c5048efb3 136
rgrover1 393:0f7c5048efb3 137 if (startHandle < endHandle) {
rgrover1 393:0f7c5048efb3 138 ble_gattc_handle_range_t handleRange = {
rgrover1 393:0f7c5048efb3 139 .start_handle = startHandle,
rgrover1 393:0f7c5048efb3 140 .end_handle = endHandle
rgrover1 393:0f7c5048efb3 141 };
rgrover1 393:0f7c5048efb3 142 if (sd_ble_gattc_characteristics_discover(connHandle, &handleRange) != NRF_SUCCESS) {
rgrover1 393:0f7c5048efb3 143 terminateCharacteristicDiscovery();
rgrover1 393:0f7c5048efb3 144 }
rgrover1 393:0f7c5048efb3 145 } else {
rgrover1 393:0f7c5048efb3 146 terminateCharacteristicDiscovery();
rgrover1 393:0f7c5048efb3 147 }
rgrover1 393:0f7c5048efb3 148 }
rgrover1 393:0f7c5048efb3 149 }
rgrover1 393:0f7c5048efb3 150
rgrover1 393:0f7c5048efb3 151 void
rgrover1 393:0f7c5048efb3 152 nRF5xServiceDiscovery::progressServiceDiscovery(void)
rgrover1 393:0f7c5048efb3 153 {
rgrover1 393:0f7c5048efb3 154 /* Iterate through the previously discovered services cached in services[]. */
rgrover1 393:0f7c5048efb3 155 while ((state == SERVICE_DISCOVERY_ACTIVE) && (serviceIndex < numServices)) {
rgrover1 393:0f7c5048efb3 156 if ((matchingServiceUUID == UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) ||
rgrover1 393:0f7c5048efb3 157 (matchingServiceUUID == services[serviceIndex].getUUID())) {
rgrover1 393:0f7c5048efb3 158
rgrover1 393:0f7c5048efb3 159 if (serviceCallback && (matchingCharacteristicUUID == UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN))) {
rgrover1 393:0f7c5048efb3 160 serviceCallback(&services[serviceIndex]);
rgrover1 393:0f7c5048efb3 161 }
rgrover1 393:0f7c5048efb3 162
rgrover1 393:0f7c5048efb3 163 if ((state == SERVICE_DISCOVERY_ACTIVE) && characteristicCallback) {
rgrover1 393:0f7c5048efb3 164 launchCharacteristicDiscovery(connHandle, services[serviceIndex].getStartHandle(), services[serviceIndex].getEndHandle());
rgrover1 393:0f7c5048efb3 165 } else {
rgrover1 393:0f7c5048efb3 166 serviceIndex++;
rgrover1 393:0f7c5048efb3 167 }
rgrover1 393:0f7c5048efb3 168 } else {
rgrover1 393:0f7c5048efb3 169 serviceIndex++;
rgrover1 393:0f7c5048efb3 170 }
rgrover1 393:0f7c5048efb3 171 }
rgrover1 393:0f7c5048efb3 172
rgrover1 393:0f7c5048efb3 173 /* Relaunch discovery of new services beyond the last entry cached in services[]. */
rgrover1 393:0f7c5048efb3 174 if ((state == SERVICE_DISCOVERY_ACTIVE) && (numServices > 0) && (serviceIndex > 0)) {
rgrover1 393:0f7c5048efb3 175 /* Determine the ending handle of the last cached service. */
rgrover1 393:0f7c5048efb3 176 Gap::Handle_t endHandle = services[serviceIndex - 1].getEndHandle();
rgrover1 393:0f7c5048efb3 177 resetDiscoveredServices(); /* Note: resetDiscoveredServices() must come after fetching endHandle. */
rgrover1 393:0f7c5048efb3 178
rgrover1 393:0f7c5048efb3 179 if (endHandle == SRV_DISC_END_HANDLE) {
rgrover1 393:0f7c5048efb3 180 terminateServiceDiscovery();
rgrover1 393:0f7c5048efb3 181 } else {
rgrover1 393:0f7c5048efb3 182 if (sd_ble_gattc_primary_services_discover(connHandle, endHandle, NULL) != NRF_SUCCESS) {
rgrover1 393:0f7c5048efb3 183 terminateServiceDiscovery();
rgrover1 393:0f7c5048efb3 184 }
rgrover1 393:0f7c5048efb3 185 }
rgrover1 393:0f7c5048efb3 186 }
rgrover1 393:0f7c5048efb3 187 }
rgrover1 393:0f7c5048efb3 188
rgrover1 393:0f7c5048efb3 189 void
rgrover1 393:0f7c5048efb3 190 nRF5xServiceDiscovery::ServiceUUIDDiscoveryQueue::triggerFirst(void)
rgrover1 393:0f7c5048efb3 191 {
rgrover1 393:0f7c5048efb3 192 while (numIndices) { /* loop until a call to char_value_by_uuid_read() succeeds or we run out of pending indices. */
rgrover1 393:0f7c5048efb3 193 parentDiscoveryObject->state = DISCOVER_SERVICE_UUIDS;
rgrover1 393:0f7c5048efb3 194
rgrover1 393:0f7c5048efb3 195 unsigned serviceIndex = getFirst();
rgrover1 393:0f7c5048efb3 196 ble_uuid_t uuid = {
rgrover1 393:0f7c5048efb3 197 .uuid = BLE_UUID_SERVICE_PRIMARY,
rgrover1 393:0f7c5048efb3 198 .type = BLE_UUID_TYPE_BLE,
rgrover1 393:0f7c5048efb3 199 };
rgrover1 393:0f7c5048efb3 200 ble_gattc_handle_range_t handleRange = {
rgrover1 393:0f7c5048efb3 201 .start_handle = parentDiscoveryObject->services[serviceIndex].getStartHandle(),
rgrover1 393:0f7c5048efb3 202 .end_handle = parentDiscoveryObject->services[serviceIndex].getEndHandle(),
rgrover1 393:0f7c5048efb3 203 };
rgrover1 393:0f7c5048efb3 204 if (sd_ble_gattc_char_value_by_uuid_read(parentDiscoveryObject->connHandle, &uuid, &handleRange) == NRF_SUCCESS) {
rgrover1 393:0f7c5048efb3 205 return;
rgrover1 393:0f7c5048efb3 206 }
rgrover1 393:0f7c5048efb3 207
rgrover1 393:0f7c5048efb3 208 /* Skip this service if we fail to launch a read for its service-declaration
rgrover1 393:0f7c5048efb3 209 * attribute. Its UUID will remain INVALID, and it may not match any filters. */
rgrover1 393:0f7c5048efb3 210 dequeue();
rgrover1 393:0f7c5048efb3 211 }
rgrover1 393:0f7c5048efb3 212
rgrover1 393:0f7c5048efb3 213 /* Switch back to service discovery upon exhausting the service-indices pending UUID discovery. */
rgrover1 393:0f7c5048efb3 214 if (parentDiscoveryObject->state == DISCOVER_SERVICE_UUIDS) {
rgrover1 393:0f7c5048efb3 215 parentDiscoveryObject->state = SERVICE_DISCOVERY_ACTIVE;
rgrover1 393:0f7c5048efb3 216 }
rgrover1 393:0f7c5048efb3 217 }
rgrover1 393:0f7c5048efb3 218
rgrover1 393:0f7c5048efb3 219 void
rgrover1 393:0f7c5048efb3 220 nRF5xServiceDiscovery::CharUUIDDiscoveryQueue::triggerFirst(void)
rgrover1 393:0f7c5048efb3 221 {
rgrover1 393:0f7c5048efb3 222 while (numIndices) { /* loop until a call to char_value_by_uuid_read() succeeds or we run out of pending indices. */
rgrover1 393:0f7c5048efb3 223 parentDiscoveryObject->state = DISCOVER_CHARACTERISTIC_UUIDS;
rgrover1 393:0f7c5048efb3 224
rgrover1 393:0f7c5048efb3 225 unsigned charIndex = getFirst();
rgrover1 393:0f7c5048efb3 226 ble_uuid_t uuid = {
rgrover1 393:0f7c5048efb3 227 .uuid = BLE_UUID_CHARACTERISTIC,
rgrover1 393:0f7c5048efb3 228 .type = BLE_UUID_TYPE_BLE,
rgrover1 393:0f7c5048efb3 229 };
rgrover1 393:0f7c5048efb3 230 ble_gattc_handle_range_t handleRange = { };
rgrover1 393:0f7c5048efb3 231 handleRange.start_handle = parentDiscoveryObject->characteristics[charIndex].getDeclHandle();
rgrover1 393:0f7c5048efb3 232 handleRange.end_handle = parentDiscoveryObject->characteristics[charIndex].getDeclHandle() + 1;
rgrover1 393:0f7c5048efb3 233 if (sd_ble_gattc_char_value_by_uuid_read(parentDiscoveryObject->connHandle, &uuid, &handleRange) == NRF_SUCCESS) {
rgrover1 393:0f7c5048efb3 234 return;
rgrover1 393:0f7c5048efb3 235 }
rgrover1 393:0f7c5048efb3 236
rgrover1 393:0f7c5048efb3 237 /* Skip this service if we fail to launch a read for its service-declaration
rgrover1 393:0f7c5048efb3 238 * attribute. Its UUID will remain INVALID, and it may not match any filters. */
rgrover1 393:0f7c5048efb3 239 dequeue();
rgrover1 393:0f7c5048efb3 240 }
rgrover1 393:0f7c5048efb3 241
rgrover1 393:0f7c5048efb3 242 /* Switch back to service discovery upon exhausting the service-indices pending UUID discovery. */
rgrover1 393:0f7c5048efb3 243 if (parentDiscoveryObject->state == DISCOVER_CHARACTERISTIC_UUIDS) {
rgrover1 393:0f7c5048efb3 244 parentDiscoveryObject->state = CHARACTERISTIC_DISCOVERY_ACTIVE;
rgrover1 393:0f7c5048efb3 245 }
rgrover1 393:0f7c5048efb3 246 }
rgrover1 393:0f7c5048efb3 247
rgrover1 393:0f7c5048efb3 248 void
rgrover1 393:0f7c5048efb3 249 nRF5xServiceDiscovery::processDiscoverUUIDResponse(const ble_gattc_evt_char_val_by_uuid_read_rsp_t *response)
rgrover1 393:0f7c5048efb3 250 {
rgrover1 393:0f7c5048efb3 251 if (state == DISCOVER_SERVICE_UUIDS) {
rgrover1 393:0f7c5048efb3 252 if ((response->count == 1) && (response->value_len == UUID::LENGTH_OF_LONG_UUID)) {
rgrover1 393:0f7c5048efb3 253 UUID::LongUUIDBytes_t uuid;
rgrover1 393:0f7c5048efb3 254 /* Switch longUUID bytes to MSB */
rgrover1 393:0f7c5048efb3 255 for (unsigned i = 0; i < UUID::LENGTH_OF_LONG_UUID; i++) {
rgrover1 393:0f7c5048efb3 256 uuid[i] = response->handle_value[0].p_value[UUID::LENGTH_OF_LONG_UUID - 1 - i];
rgrover1 393:0f7c5048efb3 257 }
rgrover1 393:0f7c5048efb3 258
rgrover1 393:0f7c5048efb3 259 unsigned serviceIndex = serviceUUIDDiscoveryQueue.dequeue();
rgrover1 393:0f7c5048efb3 260 services[serviceIndex].setupLongUUID(uuid);
rgrover1 393:0f7c5048efb3 261
rgrover1 393:0f7c5048efb3 262 serviceUUIDDiscoveryQueue.triggerFirst();
rgrover1 393:0f7c5048efb3 263 } else {
rgrover1 393:0f7c5048efb3 264 serviceUUIDDiscoveryQueue.dequeue();
rgrover1 393:0f7c5048efb3 265 }
rgrover1 393:0f7c5048efb3 266 } else if (state == DISCOVER_CHARACTERISTIC_UUIDS) {
rgrover1 393:0f7c5048efb3 267 if ((response->count == 1) && (response->value_len == UUID::LENGTH_OF_LONG_UUID + 1 /* props */ + 2 /* value handle */)) {
rgrover1 393:0f7c5048efb3 268 UUID::LongUUIDBytes_t uuid;
rgrover1 393:0f7c5048efb3 269 /* Switch longUUID bytes to MSB */
rgrover1 393:0f7c5048efb3 270 for (unsigned i = 0; i < UUID::LENGTH_OF_LONG_UUID; i++) {
rgrover1 393:0f7c5048efb3 271 uuid[i] = response->handle_value[0].p_value[3 + UUID::LENGTH_OF_LONG_UUID - 1 - i];
rgrover1 393:0f7c5048efb3 272 }
rgrover1 393:0f7c5048efb3 273
rgrover1 393:0f7c5048efb3 274 unsigned charIndex = charUUIDDiscoveryQueue.dequeue();
rgrover1 393:0f7c5048efb3 275 characteristics[charIndex].setupLongUUID(uuid);
rgrover1 393:0f7c5048efb3 276
rgrover1 393:0f7c5048efb3 277 charUUIDDiscoveryQueue.triggerFirst();
rgrover1 393:0f7c5048efb3 278 } else {
rgrover1 393:0f7c5048efb3 279 charUUIDDiscoveryQueue.dequeue();
rgrover1 393:0f7c5048efb3 280 }
rgrover1 393:0f7c5048efb3 281 }
rgrover1 393:0f7c5048efb3 282 }