From 6ef90b5ca7a0b5e30f86143104d316f0f9564d37 Mon Sep 17 00:00:00 2001 From: paul-szczepanek-arm <33840200+paul-szczepanek-arm@users.noreply.github.com> Date: Fri, 16 Nov 2018 12:28:19 +0000 Subject: [PATCH] remove data instead of replace data --- .../ble/gap/AdvertisingDataBuilder.h | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/features/FEATURE_BLE/ble/gap/AdvertisingDataBuilder.h b/features/FEATURE_BLE/ble/gap/AdvertisingDataBuilder.h index 56b93184e1..f0edfe146f 100644 --- a/features/FEATURE_BLE/ble/gap/AdvertisingDataBuilder.h +++ b/features/FEATURE_BLE/ble/gap/AdvertisingDataBuilder.h @@ -551,34 +551,21 @@ public: } /** - * Replace a specific field in the advertising payload. If the field doesn't - * exist it will be added. + * Remove existing date of given type * - * @param[in] advDataType The type of the field to update. - * @param[in] fieldData Span of data to add. + * @param[in] advDataType The type of the field to remove. * - * @return BLE_ERROR_NONE returned on success. - * @return BLE_ERROR_BUFFER_OVERFLOW if the new value causes the - * advertising buffer to overflow. - * - * @note Unlike in addData(), even if data type is INCOMPLETE_LIST_16BIT_SERVICE_IDS, - * COMPLETE_LIST_16BIT_SERVICE_IDS, INCOMPLETE_LIST_32BIT_SERVICE_IDS, - * COMPLETE_LIST_32BIT_SERVICE_IDS, INCOMPLETE_LIST_128BIT_SERVICE_IDS, - * COMPLETE_LIST_128BIT_SERVICE_IDS or LIST_128BIT_SOLICITATION_IDS, the - * supplied value is will not be appended but replaced completely. + * @return BLE_ERROR_NONE returned on success, BLE_ERROR_INVALID_PARAM if field doesn't exist */ ble_error_t removeData( - adv_data_type_t advDataType, - mbed::Span fieldData + adv_data_type_t advDataType ) { uint8_t* field = findField(advDataType); if (field) { - /* Field type already exists, replace field contents */ - return replaceField(advDataType, fieldData, field); + return removeField(field); } else { - /* field doesn't exist, add it */ - return addField(advDataType, fieldData); + return BLE_ERROR_INVALID_PARAM; } }