For with fix for disconnection notifications

Fork of nRF51822 by Nordic Semiconductor

Committer:
Rohit Grover
Date:
Thu Jul 24 15:46:29 2014 +0100
Revision:
52:120bd37b9d0d
Parent:
39:d52a28e1fa80
Child:
54:e2294c844c83
Child:
56:a1071b629aa3
implement APIs for get/setDeviceName(), get/setAppearance(), getVersion(), and setTxPower()

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rohit Grover 22:c6ee8136847e 1 /* mbed Microcontroller Library
Rohit Grover 22:c6ee8136847e 2 * Copyright (c) 2006-2013 ARM Limited
Rohit Grover 22:c6ee8136847e 3 *
Rohit Grover 22:c6ee8136847e 4 * Licensed under the Apache License, Version 2.0 (the "License");
Rohit Grover 22:c6ee8136847e 5 * you may not use this file except in compliance with the License.
Rohit Grover 22:c6ee8136847e 6 * You may obtain a copy of the License at
Rohit Grover 22:c6ee8136847e 7 *
Rohit Grover 22:c6ee8136847e 8 * http://www.apache.org/licenses/LICENSE-2.0
Rohit Grover 22:c6ee8136847e 9 *
Rohit Grover 22:c6ee8136847e 10 * Unless required by applicable law or agreed to in writing, software
Rohit Grover 22:c6ee8136847e 11 * distributed under the License is distributed on an "AS IS" BASIS,
Rohit Grover 22:c6ee8136847e 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Rohit Grover 22:c6ee8136847e 13 * See the License for the specific language governing permissions and
Rohit Grover 22:c6ee8136847e 14 * limitations under the License.
Rohit Grover 22:c6ee8136847e 15 */
Rohit Grover 22:c6ee8136847e 16
Rohit Grover 22:c6ee8136847e 17 #include "nRF51GattServer.h"
Rohit Grover 22:c6ee8136847e 18 #include "mbed.h"
Rohit Grover 22:c6ee8136847e 19
Rohit Grover 22:c6ee8136847e 20 #include "common/common.h"
Rohit Grover 22:c6ee8136847e 21 #include "btle/custom/custom_helper.h"
Rohit Grover 22:c6ee8136847e 22
Rohit Grover 22:c6ee8136847e 23 #include "nRF51Gap.h"
Rohit Grover 22:c6ee8136847e 24
Rohit Grover 22:c6ee8136847e 25 /**************************************************************************/
Rohit Grover 22:c6ee8136847e 26 /*!
Rohit Grover 22:c6ee8136847e 27 @brief Adds a new service to the GATT table on the peripheral
Rohit Grover 22:c6ee8136847e 28
Rohit Grover 22:c6ee8136847e 29 @returns ble_error_t
Rohit Grover 22:c6ee8136847e 30
Rohit Grover 22:c6ee8136847e 31 @retval BLE_ERROR_NONE
Rohit Grover 22:c6ee8136847e 32 Everything executed properly
Rohit Grover 22:c6ee8136847e 33
Rohit Grover 22:c6ee8136847e 34 @section EXAMPLE
Rohit Grover 22:c6ee8136847e 35
Rohit Grover 22:c6ee8136847e 36 @code
Rohit Grover 22:c6ee8136847e 37
Rohit Grover 22:c6ee8136847e 38 @endcode
Rohit Grover 22:c6ee8136847e 39 */
Rohit Grover 22:c6ee8136847e 40 /**************************************************************************/
Rohit Grover 22:c6ee8136847e 41 ble_error_t nRF51GattServer::addService(GattService &service)
Rohit Grover 22:c6ee8136847e 42 {
Rohit Grover 22:c6ee8136847e 43 /* ToDo: Make sure we don't overflow the array, etc. */
Rohit Grover 22:c6ee8136847e 44 /* ToDo: Make sure this service UUID doesn't already exist (?) */
Rohit Grover 22:c6ee8136847e 45 /* ToDo: Basic validation */
Rohit Grover 22:c6ee8136847e 46
Rohit Grover 22:c6ee8136847e 47 /* Add the service to the nRF51 */
Rohit Grover 22:c6ee8136847e 48 ble_uuid_t nordicUUID;
Rohit Grover 22:c6ee8136847e 49 nordicUUID = custom_convert_to_nordic_uuid(service.getUUID());
Rohit Grover 29:cee837a465a1 50
Rohit Grover 29:cee837a465a1 51 uint16_t serviceHandle;
Rohit Grover 22:c6ee8136847e 52 ASSERT( ERROR_NONE ==
Rohit Grover 22:c6ee8136847e 53 sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
Rohit Grover 22:c6ee8136847e 54 &nordicUUID,
Rohit Grover 29:cee837a465a1 55 &serviceHandle),
Rohit Grover 22:c6ee8136847e 56 BLE_ERROR_PARAM_OUT_OF_RANGE );
Rohit Grover 29:cee837a465a1 57 service.setHandle(serviceHandle);
Rohit Grover 22:c6ee8136847e 58
Rohit Grover 22:c6ee8136847e 59 /* Add characteristics to the service */
Rohit Grover 22:c6ee8136847e 60 for (uint8_t i = 0; i < service.getCharacteristicCount(); i++) {
Rohit Grover 22:c6ee8136847e 61 GattCharacteristic *p_char = service.getCharacteristic(i);
Rohit Grover 22:c6ee8136847e 62
Rohit Grover 22:c6ee8136847e 63 nordicUUID = custom_convert_to_nordic_uuid(p_char->getUUID());
Rohit Grover 22:c6ee8136847e 64
Rohit Grover 22:c6ee8136847e 65 ASSERT ( ERROR_NONE ==
Rohit Grover 22:c6ee8136847e 66 custom_add_in_characteristic(service.getHandle(),
Rohit Grover 22:c6ee8136847e 67 &nordicUUID,
Rohit Grover 22:c6ee8136847e 68 p_char->getProperties(),
Rohit Grover 22:c6ee8136847e 69 NULL,
Rohit Grover 27:2a1c1825b7be 70 p_char->getInitialLength(),
Rohit Grover 22:c6ee8136847e 71 p_char->getMaxLength(),
Rohit Grover 22:c6ee8136847e 72 &nrfCharacteristicHandles[characteristicCount]),
Rohit Grover 22:c6ee8136847e 73 BLE_ERROR_PARAM_OUT_OF_RANGE );
Rohit Grover 22:c6ee8136847e 74
Rohit Grover 22:c6ee8136847e 75 /* Update the characteristic handle */
Rohit Grover 28:fdc1a88a80c8 76 uint16_t charHandle = characteristicCount;
Rohit Grover 22:c6ee8136847e 77 p_characteristics[characteristicCount++] = p_char;
Rohit Grover 28:fdc1a88a80c8 78
Rohit Grover 28:fdc1a88a80c8 79 p_char->setHandle(charHandle);
Rohit Grover 30:85305292b44f 80 if ((p_char->getValuePtr() != NULL) && (p_char->getInitialLength() > 0)) {
Rohit Grover 30:85305292b44f 81 updateValue(charHandle, p_char->getValuePtr(), p_char->getInitialLength(), false /* localOnly */);
Rohit Grover 30:85305292b44f 82 }
Rohit Grover 22:c6ee8136847e 83 }
Rohit Grover 22:c6ee8136847e 84
Rohit Grover 22:c6ee8136847e 85 serviceCount++;
Rohit Grover 22:c6ee8136847e 86
Rohit Grover 22:c6ee8136847e 87 return BLE_ERROR_NONE;
Rohit Grover 22:c6ee8136847e 88 }
Rohit Grover 22:c6ee8136847e 89
Rohit Grover 22:c6ee8136847e 90 /**************************************************************************/
Rohit Grover 22:c6ee8136847e 91 /*!
Rohit Grover 22:c6ee8136847e 92 @brief Reads the value of a characteristic, based on the service
Rohit Grover 22:c6ee8136847e 93 and characteristic index fields
Rohit Grover 22:c6ee8136847e 94
Rohit Grover 22:c6ee8136847e 95 @param[in] charHandle
Rohit Grover 22:c6ee8136847e 96 The handle of the GattCharacteristic to read from
Rohit Grover 22:c6ee8136847e 97 @param[in] buffer
Rohit Grover 22:c6ee8136847e 98 Buffer to hold the the characteristic's value
Rohit Grover 22:c6ee8136847e 99 (raw byte array in LSB format)
Rohit Grover 22:c6ee8136847e 100 @param[in] len
Rohit Grover 22:c6ee8136847e 101 The number of bytes read into the buffer
Rohit Grover 22:c6ee8136847e 102
Rohit Grover 22:c6ee8136847e 103 @returns ble_error_t
Rohit Grover 22:c6ee8136847e 104
Rohit Grover 22:c6ee8136847e 105 @retval BLE_ERROR_NONE
Rohit Grover 22:c6ee8136847e 106 Everything executed properly
Rohit Grover 22:c6ee8136847e 107
Rohit Grover 22:c6ee8136847e 108 @section EXAMPLE
Rohit Grover 22:c6ee8136847e 109
Rohit Grover 22:c6ee8136847e 110 @code
Rohit Grover 22:c6ee8136847e 111
Rohit Grover 22:c6ee8136847e 112 @endcode
Rohit Grover 22:c6ee8136847e 113 */
Rohit Grover 22:c6ee8136847e 114 /**************************************************************************/
Rohit Grover 31:c3ce6ee5d300 115 ble_error_t nRF51GattServer::readValue(uint16_t charHandle, uint8_t buffer[], uint16_t *const lengthP)
Rohit Grover 22:c6ee8136847e 116 {
Rohit Grover 22:c6ee8136847e 117 ASSERT( ERROR_NONE ==
Rohit Grover 31:c3ce6ee5d300 118 sd_ble_gatts_value_get(nrfCharacteristicHandles[charHandle].value_handle, 0, lengthP, buffer),
Rohit Grover 22:c6ee8136847e 119 BLE_ERROR_PARAM_OUT_OF_RANGE);
Rohit Grover 22:c6ee8136847e 120
Rohit Grover 22:c6ee8136847e 121 return BLE_ERROR_NONE;
Rohit Grover 22:c6ee8136847e 122 }
Rohit Grover 22:c6ee8136847e 123
Rohit Grover 22:c6ee8136847e 124 /**************************************************************************/
Rohit Grover 22:c6ee8136847e 125 /*!
Rohit Grover 22:c6ee8136847e 126 @brief Updates the value of a characteristic, based on the service
Rohit Grover 22:c6ee8136847e 127 and characteristic index fields
Rohit Grover 22:c6ee8136847e 128
Rohit Grover 22:c6ee8136847e 129 @param[in] charHandle
Rohit Grover 22:c6ee8136847e 130 The handle of the GattCharacteristic to write to
Rohit Grover 22:c6ee8136847e 131 @param[in] buffer
Rohit Grover 22:c6ee8136847e 132 Data to use when updating the characteristic's value
Rohit Grover 22:c6ee8136847e 133 (raw byte array in LSB format)
Rohit Grover 22:c6ee8136847e 134 @param[in] len
Rohit Grover 22:c6ee8136847e 135 The number of bytes in buffer
Rohit Grover 22:c6ee8136847e 136
Rohit Grover 22:c6ee8136847e 137 @returns ble_error_t
Rohit Grover 22:c6ee8136847e 138
Rohit Grover 22:c6ee8136847e 139 @retval BLE_ERROR_NONE
Rohit Grover 22:c6ee8136847e 140 Everything executed properly
Rohit Grover 22:c6ee8136847e 141
Rohit Grover 22:c6ee8136847e 142 @section EXAMPLE
Rohit Grover 22:c6ee8136847e 143
Rohit Grover 22:c6ee8136847e 144 @code
Rohit Grover 22:c6ee8136847e 145
Rohit Grover 22:c6ee8136847e 146 @endcode
Rohit Grover 22:c6ee8136847e 147 */
Rohit Grover 22:c6ee8136847e 148 /**************************************************************************/
Rohit Grover 22:c6ee8136847e 149 ble_error_t nRF51GattServer::updateValue(uint16_t charHandle, uint8_t buffer[], uint16_t len, bool localOnly)
Rohit Grover 22:c6ee8136847e 150 {
Rohit Grover 22:c6ee8136847e 151 uint16_t gapConnectionHandle = nRF51Gap::getInstance().getConnectionHandle();
Rohit Grover 22:c6ee8136847e 152
Rohit Grover 22:c6ee8136847e 153 if (localOnly) {
Rohit Grover 22:c6ee8136847e 154 /* Only update locally regardless of notify/indicate */
Rohit Grover 22:c6ee8136847e 155 ASSERT_INT( ERROR_NONE,
Rohit Grover 22:c6ee8136847e 156 sd_ble_gatts_value_set(nrfCharacteristicHandles[charHandle].value_handle, 0, &len, buffer),
Rohit Grover 22:c6ee8136847e 157 BLE_ERROR_PARAM_OUT_OF_RANGE );
Rohit Grover 38:dc4d0edf9bb9 158 return BLE_ERROR_NONE;
Rohit Grover 22:c6ee8136847e 159 }
Rohit Grover 22:c6ee8136847e 160
Rohit Grover 22:c6ee8136847e 161 if ((p_characteristics[charHandle]->getProperties() &
Rohit Grover 22:c6ee8136847e 162 (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE |
Rohit Grover 22:c6ee8136847e 163 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)) &&
Rohit Grover 22:c6ee8136847e 164 (gapConnectionHandle != BLE_CONN_HANDLE_INVALID)) {
Rohit Grover 22:c6ee8136847e 165 /* HVX update for the characteristic value */
Rohit Grover 22:c6ee8136847e 166 ble_gatts_hvx_params_t hvx_params;
Rohit Grover 22:c6ee8136847e 167
Rohit Grover 22:c6ee8136847e 168 hvx_params.handle = nrfCharacteristicHandles[charHandle].value_handle;
Rohit Grover 22:c6ee8136847e 169 hvx_params.type =
Rohit Grover 22:c6ee8136847e 170 (p_characteristics[charHandle]->getProperties() &
Rohit Grover 22:c6ee8136847e 171 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) ?
Rohit Grover 22:c6ee8136847e 172 BLE_GATT_HVX_NOTIFICATION : BLE_GATT_HVX_INDICATION;
Rohit Grover 22:c6ee8136847e 173 hvx_params.offset = 0;
Rohit Grover 22:c6ee8136847e 174 hvx_params.p_data = buffer;
Rohit Grover 22:c6ee8136847e 175 hvx_params.p_len = &len;
Rohit Grover 22:c6ee8136847e 176
Rohit Grover 22:c6ee8136847e 177 error_t error = (error_t) sd_ble_gatts_hvx(gapConnectionHandle, &hvx_params);
Rohit Grover 22:c6ee8136847e 178
Rohit Grover 22:c6ee8136847e 179 /* ERROR_INVALID_STATE, ERROR_BUSY, ERROR_GATTS_SYS_ATTR_MISSING and
Rohit Grover 22:c6ee8136847e 180 *ERROR_NO_TX_BUFFERS the ATT table has been updated. */
Rohit Grover 22:c6ee8136847e 181 if ((error != ERROR_NONE) && (error != ERROR_INVALID_STATE) &&
Rohit Grover 22:c6ee8136847e 182 (error != ERROR_BLE_NO_TX_BUFFERS) && (error != ERROR_BUSY) &&
Rohit Grover 22:c6ee8136847e 183 (error != ERROR_BLEGATTS_SYS_ATTR_MISSING)) {
Rohit Grover 22:c6ee8136847e 184 ASSERT_INT( ERROR_NONE,
Rohit Grover 22:c6ee8136847e 185 sd_ble_gatts_value_set(nrfCharacteristicHandles[charHandle].value_handle, 0, &len, buffer),
Rohit Grover 22:c6ee8136847e 186 BLE_ERROR_PARAM_OUT_OF_RANGE );
Rohit Grover 22:c6ee8136847e 187 }
Rohit Grover 22:c6ee8136847e 188 } else {
Rohit Grover 22:c6ee8136847e 189 ASSERT_INT( ERROR_NONE,
Rohit Grover 22:c6ee8136847e 190 sd_ble_gatts_value_set(nrfCharacteristicHandles[charHandle].value_handle, 0, &len, buffer),
Rohit Grover 22:c6ee8136847e 191 BLE_ERROR_PARAM_OUT_OF_RANGE );
Rohit Grover 22:c6ee8136847e 192 }
Rohit Grover 22:c6ee8136847e 193
Rohit Grover 22:c6ee8136847e 194 return BLE_ERROR_NONE;
Rohit Grover 22:c6ee8136847e 195 }
Rohit Grover 22:c6ee8136847e 196
Rohit Grover 52:120bd37b9d0d 197 ble_error_t nRF51GattServer::setDeviceName(const uint8_t *deviceName)
Rohit Grover 52:120bd37b9d0d 198 {
Rohit Grover 52:120bd37b9d0d 199 ble_gap_conn_sec_mode_t sec_mode;
Rohit Grover 52:120bd37b9d0d 200 BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // no security is needed
Rohit Grover 52:120bd37b9d0d 201
Rohit Grover 52:120bd37b9d0d 202 if (sd_ble_gap_device_name_set(&sec_mode, deviceName, strlen((const char *)deviceName)) == NRF_SUCCESS) {
Rohit Grover 52:120bd37b9d0d 203 return BLE_ERROR_NONE;
Rohit Grover 52:120bd37b9d0d 204 } else {
Rohit Grover 52:120bd37b9d0d 205 return BLE_ERROR_PARAM_OUT_OF_RANGE;
Rohit Grover 52:120bd37b9d0d 206 }
Rohit Grover 52:120bd37b9d0d 207 }
Rohit Grover 52:120bd37b9d0d 208
Rohit Grover 52:120bd37b9d0d 209 ble_error_t nRF51GattServer::getDeviceName(uint8_t *deviceName, unsigned *lengthP)
Rohit Grover 52:120bd37b9d0d 210 {
Rohit Grover 52:120bd37b9d0d 211 if (sd_ble_gap_device_name_get(deviceName, (uint16_t *)lengthP) == NRF_SUCCESS) {
Rohit Grover 52:120bd37b9d0d 212 return BLE_ERROR_NONE;
Rohit Grover 52:120bd37b9d0d 213 } else {
Rohit Grover 52:120bd37b9d0d 214 return BLE_ERROR_PARAM_OUT_OF_RANGE;
Rohit Grover 52:120bd37b9d0d 215 }
Rohit Grover 52:120bd37b9d0d 216 }
Rohit Grover 52:120bd37b9d0d 217
Rohit Grover 52:120bd37b9d0d 218 ble_error_t nRF51GattServer::setAppearance(uint16_t appearance)
Rohit Grover 52:120bd37b9d0d 219 {
Rohit Grover 52:120bd37b9d0d 220 if (sd_ble_gap_appearance_set(appearance) == NRF_SUCCESS) {
Rohit Grover 52:120bd37b9d0d 221 return BLE_ERROR_NONE;
Rohit Grover 52:120bd37b9d0d 222 } else {
Rohit Grover 52:120bd37b9d0d 223 return BLE_ERROR_PARAM_OUT_OF_RANGE;
Rohit Grover 52:120bd37b9d0d 224 }
Rohit Grover 52:120bd37b9d0d 225 }
Rohit Grover 52:120bd37b9d0d 226
Rohit Grover 52:120bd37b9d0d 227 ble_error_t nRF51GattServer::getAppearance(uint16_t *appearanceP)
Rohit Grover 52:120bd37b9d0d 228 {
Rohit Grover 52:120bd37b9d0d 229 if (sd_ble_gap_appearance_get(appearanceP)) {
Rohit Grover 52:120bd37b9d0d 230 return BLE_ERROR_NONE;
Rohit Grover 52:120bd37b9d0d 231 } else {
Rohit Grover 52:120bd37b9d0d 232 return BLE_ERROR_PARAM_OUT_OF_RANGE;
Rohit Grover 52:120bd37b9d0d 233 }
Rohit Grover 52:120bd37b9d0d 234 }
Rohit Grover 52:120bd37b9d0d 235
Rohit Grover 22:c6ee8136847e 236 /**************************************************************************/
Rohit Grover 22:c6ee8136847e 237 /*!
Rohit Grover 22:c6ee8136847e 238 @brief Callback handler for events getting pushed up from the SD
Rohit Grover 22:c6ee8136847e 239 */
Rohit Grover 22:c6ee8136847e 240 /**************************************************************************/
Rohit Grover 22:c6ee8136847e 241 void nRF51GattServer::hwCallback(ble_evt_t *p_ble_evt)
Rohit Grover 22:c6ee8136847e 242 {
Rohit Grover 22:c6ee8136847e 243 uint16_t handle_value;
Rohit Grover 22:c6ee8136847e 244 GattServerEvents::gattEvent_t event;
Rohit Grover 22:c6ee8136847e 245
Rohit Grover 22:c6ee8136847e 246 switch (p_ble_evt->header.evt_id) {
Rohit Grover 22:c6ee8136847e 247 case BLE_GATTS_EVT_WRITE:
Rohit Grover 22:c6ee8136847e 248 /* There are 2 use case here: Values being updated & CCCD (indicate/notify) enabled */
Rohit Grover 22:c6ee8136847e 249
Rohit Grover 22:c6ee8136847e 250 /* 1.) Handle CCCD changes */
Rohit Grover 22:c6ee8136847e 251 handle_value = p_ble_evt->evt.gatts_evt.params.write.handle;
Rohit Grover 22:c6ee8136847e 252 for (uint8_t i = 0; i<characteristicCount; i++) {
Rohit Grover 35:7174913c9d67 253 if ((p_characteristics[i]->getProperties() & (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY)) &&
Rohit Grover 35:7174913c9d67 254 (nrfCharacteristicHandles[i].cccd_handle == handle_value)) {
Rohit Grover 22:c6ee8136847e 255 uint16_t cccd_value =
Rohit Grover 22:c6ee8136847e 256 (p_ble_evt->evt.gatts_evt.params.write.data[1] << 8) |
Rohit Grover 22:c6ee8136847e 257 p_ble_evt->evt.gatts_evt.params.write.data[0]; /* Little Endian but M0 may be mis-aligned */
Rohit Grover 22:c6ee8136847e 258
Rohit Grover 35:7174913c9d67 259 if (((p_characteristics[i]->getProperties() & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE) && (cccd_value & BLE_GATT_HVX_INDICATION)) ||
Rohit Grover 35:7174913c9d67 260 ((p_characteristics[i]->getProperties() & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) && (cccd_value & BLE_GATT_HVX_NOTIFICATION))) {
Rohit Grover 22:c6ee8136847e 261 event = GattServerEvents::GATT_EVENT_UPDATES_ENABLED;
Rohit Grover 22:c6ee8136847e 262 } else {
Rohit Grover 22:c6ee8136847e 263 event = GattServerEvents::GATT_EVENT_UPDATES_DISABLED;
Rohit Grover 22:c6ee8136847e 264 }
Rohit Grover 22:c6ee8136847e 265
Rohit Grover 22:c6ee8136847e 266 handleEvent(event, i);
Rohit Grover 22:c6ee8136847e 267 return;
Rohit Grover 22:c6ee8136847e 268 }
Rohit Grover 22:c6ee8136847e 269 }
Rohit Grover 22:c6ee8136847e 270
Rohit Grover 34:48d24b1d2fe6 271 /* 2.) Changes to the characteristic value will be handled with other events below */
Rohit Grover 22:c6ee8136847e 272 event = GattServerEvents::GATT_EVENT_DATA_WRITTEN;
Rohit Grover 22:c6ee8136847e 273 break;
Rohit Grover 22:c6ee8136847e 274
Rohit Grover 36:bd0186ce644a 275 case BLE_EVT_TX_COMPLETE:
Rohit Grover 36:bd0186ce644a 276 handleEvent(GattServerEvents::GATT_EVENT_DATA_SENT);
Rohit Grover 36:bd0186ce644a 277 return;
Rohit Grover 36:bd0186ce644a 278
Rohit Grover 22:c6ee8136847e 279 case BLE_GATTS_EVT_HVC:
Rohit Grover 22:c6ee8136847e 280 /* Indication confirmation received */
Rohit Grover 22:c6ee8136847e 281 event = GattServerEvents::GATT_EVENT_CONFIRMATION_RECEIVED;
Rohit Grover 22:c6ee8136847e 282 handle_value = p_ble_evt->evt.gatts_evt.params.hvc.handle;
Rohit Grover 22:c6ee8136847e 283 break;
Rohit Grover 22:c6ee8136847e 284
Rohit Grover 39:d52a28e1fa80 285 case BLE_GATTS_EVT_SYS_ATTR_MISSING:
Rohit Grover 39:d52a28e1fa80 286 sd_ble_gatts_sys_attr_set(p_ble_evt->evt.gatts_evt.conn_handle, NULL, 0);
Rohit Grover 39:d52a28e1fa80 287 return;
Rohit Grover 39:d52a28e1fa80 288
Rohit Grover 22:c6ee8136847e 289 default:
Rohit Grover 22:c6ee8136847e 290 return;
Rohit Grover 22:c6ee8136847e 291 }
Rohit Grover 22:c6ee8136847e 292
Rohit Grover 22:c6ee8136847e 293 /* Find index (charHandle) in the pool */
Rohit Grover 22:c6ee8136847e 294 for (uint8_t i = 0; i<characteristicCount; i++) {
Rohit Grover 22:c6ee8136847e 295 if (nrfCharacteristicHandles[i].value_handle == handle_value) {
Rohit Grover 22:c6ee8136847e 296 handleEvent(event, i);
Rohit Grover 22:c6ee8136847e 297 break;
Rohit Grover 22:c6ee8136847e 298 }
Rohit Grover 22:c6ee8136847e 299 }
Rohit Grover 22:c6ee8136847e 300 }