Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of nRF51822 by
Diff: nRF51GattServer.cpp
- Revision:
- 54:e2294c844c83
- Parent:
- 52:120bd37b9d0d
- Child:
- 55:9689ec201907
--- a/nRF51GattServer.cpp Fri Jul 25 10:33:52 2014 +0100 +++ b/nRF51GattServer.cpp Thu Aug 28 15:50:59 2014 +0200 @@ -63,10 +63,10 @@ nordicUUID = custom_convert_to_nordic_uuid(p_char->getUUID()); ASSERT ( ERROR_NONE == - custom_add_in_characteristic(service.getHandle(), + custom_add_in_characteristic(BLE_GATT_HANDLE_INVALID, &nordicUUID, p_char->getProperties(), - NULL, + p_char->getValuePtr(), p_char->getInitialLength(), p_char->getMaxLength(), &nrfCharacteristicHandles[characteristicCount]), @@ -77,9 +77,28 @@ p_characteristics[characteristicCount++] = p_char; p_char->setHandle(charHandle); - if ((p_char->getValuePtr() != NULL) && (p_char->getInitialLength() > 0)) { - updateValue(charHandle, p_char->getValuePtr(), p_char->getInitialLength(), false /* localOnly */); + + /* Add optional descriptors if any */ + /* ToDo: Make sure we don't overflow the array */ + for (uint8_t j = 0; j < p_char->getDescriptorCount(); j++) { + GattAttribute *p_desc = p_char->getDescriptor(j); + + nordicUUID = custom_convert_to_nordic_uuid(p_desc->getUUID()); + + ASSERT ( ERROR_NONE == + custom_add_in_descriptor(BLE_GATT_HANDLE_INVALID, + &nordicUUID, + p_desc->getValuePtr(), + p_desc->getInitialLength(), + p_desc->getMaxLength(), + &nrfDescriptorHandles[descriptorCount]), + BLE_ERROR_PARAM_OUT_OF_RANGE ); + + uint16_t descHandle = descriptorCount; + p_descriptors[descriptorCount++] = p_desc; + p_desc->setHandle(descHandle); } + } serviceCount++; @@ -272,8 +291,10 @@ event = GattServerEvents::GATT_EVENT_DATA_WRITTEN; break; - case BLE_EVT_TX_COMPLETE: - handleEvent(GattServerEvents::GATT_EVENT_DATA_SENT); + case BLE_EVT_TX_COMPLETE: + for (uint8_t i = 0; i<p_ble_evt->evt.common_evt.params.tx_complete.count; i++){ + handleEvent(GattServerEvents::GATT_EVENT_DATA_SENT); + } return; case BLE_GATTS_EVT_HVC: