mirror of https://github.com/ARMmbed/mbed-os.git
remove data instead of replace data
parent
862775d3df
commit
6ef90b5ca7
|
@ -551,34 +551,21 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace a specific field in the advertising payload. If the field doesn't
|
* Remove existing date of given type
|
||||||
* exist it will be added.
|
|
||||||
*
|
*
|
||||||
* @param[in] advDataType The type of the field to update.
|
* @param[in] advDataType The type of the field to remove.
|
||||||
* @param[in] fieldData Span of data to add.
|
|
||||||
*
|
*
|
||||||
* @return BLE_ERROR_NONE returned on success.
|
* @return BLE_ERROR_NONE returned on success, BLE_ERROR_INVALID_PARAM if field doesn't exist
|
||||||
* @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.
|
|
||||||
*/
|
*/
|
||||||
ble_error_t removeData(
|
ble_error_t removeData(
|
||||||
adv_data_type_t advDataType,
|
adv_data_type_t advDataType
|
||||||
mbed::Span<const uint8_t> fieldData
|
|
||||||
) {
|
) {
|
||||||
uint8_t* field = findField(advDataType);
|
uint8_t* field = findField(advDataType);
|
||||||
|
|
||||||
if (field) {
|
if (field) {
|
||||||
/* Field type already exists, replace field contents */
|
return removeField(field);
|
||||||
return replaceField(advDataType, fieldData, field);
|
|
||||||
} else {
|
} else {
|
||||||
/* field doesn't exist, add it */
|
return BLE_ERROR_INVALID_PARAM;
|
||||||
return addField(advDataType, fieldData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue