Merge pull request #9921 from desmond-blue/fix_Cordio-insert-characteristic-handle-error

BLE:Cordio:Fix insert characteristic not handle error
pull/10081/head
Cruz Monrreal 2019-03-16 22:54:37 -05:00 committed by GitHub
commit 7fa995860f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 3 deletions

View File

@ -196,22 +196,32 @@ ble_error_t GattServer::insert_characteristic(
// Create Characteristic Declaration Attribute // Create Characteristic Declaration Attribute
insert_characteristic_declaration_attribute(characteristic, attribute_it); insert_characteristic_declaration_attribute(characteristic, attribute_it);
insert_characteristic_value_attribute(characteristic, attribute_it); ble_error_t err = insert_characteristic_value_attribute(characteristic, attribute_it);
if (err) {
return err;
}
// insert descriptors // insert descriptors
bool cccd_created = false; bool cccd_created = false;
for (size_t i = 0; i < characteristic->getDescriptorCount(); i++) { for (size_t i = 0; i < characteristic->getDescriptorCount(); i++) {
insert_descriptor( err = insert_descriptor(
characteristic, characteristic,
characteristic->getDescriptor(i), characteristic->getDescriptor(i),
attribute_it, attribute_it,
cccd_created cccd_created
); );
if (err) {
return err;
}
} }
// insert implicit CCCD // insert implicit CCCD
if ((properties & UPDATE_PROPERTIES) && (cccd_created == false)) { if ((properties & UPDATE_PROPERTIES) && (cccd_created == false)) {
insert_cccd(characteristic, attribute_it); err = insert_cccd(characteristic, attribute_it);
if (err) {
return err;
}
} }
return BLE_ERROR_NONE; return BLE_ERROR_NONE;