Skip to content

Commit a665f3e

Browse files
committed
Nordic: Set handle of user description descriptors.
1 parent 4e22295 commit a665f3e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/source/nRF5xGattServer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
6565
return BLE_ERROR_NO_MEM;
6666
}
6767
GattCharacteristic *p_char = service.getCharacteristic(i);
68+
GattAttribute *p_description_descriptor = NULL;
6869

6970
/* Skip any incompletely defined, read-only characteristics. */
7071
if ((p_char->getValueAttribute().getValuePtr() == NULL) &&
@@ -83,6 +84,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
8384
for (uint8_t j = 0; j < p_char->getDescriptorCount(); j++) {
8485
GattAttribute *p_desc = p_char->getDescriptor(j);
8586
if (p_desc->getUUID() == BLE_UUID_DESCRIPTOR_CHAR_USER_DESC) {
87+
p_description_descriptor = p_desc;
8688
userDescriptionDescriptorValuePtr = p_desc->getValuePtr();
8789
userDescriptionDescriptorValueLen = p_desc->getLength();
8890
}
@@ -107,6 +109,11 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
107109
/* Update the characteristic handle */
108110
p_characteristics[characteristicCount] = p_char;
109111
p_char->getValueAttribute().setHandle(nrfCharacteristicHandles[characteristicCount].value_handle);
112+
if (p_description_descriptor) {
113+
p_description_descriptor->setHandle(
114+
nrfCharacteristicHandles[characteristicCount].user_desc_handle
115+
);
116+
}
110117
characteristicCount++;
111118

112119
/* Add optional descriptors if any */

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5xGattServer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
106106
return BLE_ERROR_NO_MEM;
107107
}
108108
GattCharacteristic *p_char = service.getCharacteristic(i);
109+
GattAttribute *p_description_descriptor = NULL;
109110

110111
/* Skip any incompletely defined, read-only characteristics. */
111112
if ((p_char->getValueAttribute().getValuePtr() == NULL) &&
@@ -124,6 +125,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
124125
for (uint8_t j = 0; j < p_char->getDescriptorCount(); j++) {
125126
GattAttribute *p_desc = p_char->getDescriptor(j);
126127
if (p_desc->getUUID() == BLE_UUID_DESCRIPTOR_CHAR_USER_DESC) {
128+
p_description_descriptor = p_desc;
127129
userDescriptionDescriptorValuePtr = p_desc->getValuePtr();
128130
userDescriptionDescriptorValueLen = p_desc->getLength();
129131
}
@@ -148,6 +150,11 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
148150
/* Update the characteristic handle */
149151
p_characteristics[characteristicCount] = p_char;
150152
p_char->getValueAttribute().setHandle(nrfCharacteristicHandles[characteristicCount].value_handle);
153+
if (p_description_descriptor) {
154+
p_description_descriptor->setHandle(
155+
nrfCharacteristicHandles[characteristicCount].user_desc_handle
156+
);
157+
}
151158
characteristicCount++;
152159

153160
/* Add optional descriptors if any */

0 commit comments

Comments
 (0)