Skip to content

Commit 969f8af

Browse files
authored
Merge pull request #5589 from pan-/ble-nordic-set-description-handle
Nordic: Set handle of user description descriptors.
2 parents aa176ee + a665f3e commit 969f8af

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
@@ -93,6 +93,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
9393
return BLE_ERROR_NO_MEM;
9494
}
9595
GattCharacteristic *p_char = service.getCharacteristic(i);
96+
GattAttribute *p_description_descriptor = NULL;
9697

9798
/* Skip any incompletely defined, read-only characteristics. */
9899
if ((p_char->getValueAttribute().getValuePtr() == NULL) &&
@@ -111,6 +112,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
111112
for (uint8_t j = 0; j < p_char->getDescriptorCount(); j++) {
112113
GattAttribute *p_desc = p_char->getDescriptor(j);
113114
if (p_desc->getUUID() == BLE_UUID_DESCRIPTOR_CHAR_USER_DESC) {
115+
p_description_descriptor = p_desc;
114116
userDescriptionDescriptorValuePtr = p_desc->getValuePtr();
115117
userDescriptionDescriptorValueLen = p_desc->getLength();
116118
}
@@ -135,6 +137,11 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
135137
/* Update the characteristic handle */
136138
p_characteristics[characteristicCount] = p_char;
137139
p_char->getValueAttribute().setHandle(nrfCharacteristicHandles[characteristicCount].value_handle);
140+
if (p_description_descriptor) {
141+
p_description_descriptor->setHandle(
142+
nrfCharacteristicHandles[characteristicCount].user_desc_handle
143+
);
144+
}
138145
characteristicCount++;
139146

140147
/* 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
@@ -130,6 +130,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
130130
return BLE_ERROR_NO_MEM;
131131
}
132132
GattCharacteristic *p_char = service.getCharacteristic(i);
133+
GattAttribute *p_description_descriptor = NULL;
133134

134135
/* Skip any incompletely defined, read-only characteristics. */
135136
if ((p_char->getValueAttribute().getValuePtr() == NULL) &&
@@ -148,6 +149,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
148149
for (uint8_t j = 0; j < p_char->getDescriptorCount(); j++) {
149150
GattAttribute *p_desc = p_char->getDescriptor(j);
150151
if (p_desc->getUUID() == BLE_UUID_DESCRIPTOR_CHAR_USER_DESC) {
152+
p_description_descriptor = p_desc;
151153
userDescriptionDescriptorValuePtr = p_desc->getValuePtr();
152154
userDescriptionDescriptorValueLen = p_desc->getLength();
153155
}
@@ -172,6 +174,11 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
172174
/* Update the characteristic handle */
173175
p_characteristics[characteristicCount] = p_char;
174176
p_char->getValueAttribute().setHandle(nrfCharacteristicHandles[characteristicCount].value_handle);
177+
if (p_description_descriptor) {
178+
p_description_descriptor->setHandle(
179+
nrfCharacteristicHandles[characteristicCount].user_desc_handle
180+
);
181+
}
175182
characteristicCount++;
176183

177184
/* Add optional descriptors if any */

0 commit comments

Comments
 (0)