From 7dd90e181098eb66039c2ffedc0c8babfd949cda Mon Sep 17 00:00:00 2001 From: paul-szczepanek-arm <33840200+paul-szczepanek-arm@users.noreply.github.com> Date: Tue, 11 Dec 2018 17:01:17 +0000 Subject: [PATCH] Docuement active set length and add informative call for querying the limit --- features/FEATURE_BLE/ble/gap/Gap.h | 19 +++++++++++++++++++ features/FEATURE_BLE/ble/generic/GenericGap.h | 4 ++++ features/FEATURE_BLE/source/gap/Gap.cpp | 6 ++++++ .../FEATURE_BLE/source/generic/GenericGap.cpp | 6 ++++++ 4 files changed, 35 insertions(+) diff --git a/features/FEATURE_BLE/ble/gap/Gap.h b/features/FEATURE_BLE/ble/gap/Gap.h index 0a5835c6c7..2fad7af116 100644 --- a/features/FEATURE_BLE/ble/gap/Gap.h +++ b/features/FEATURE_BLE/ble/gap/Gap.h @@ -544,6 +544,12 @@ public: */ virtual uint16_t getMaxConnectableAdvertisingDataLength(); + /** Return maximum advertising data length you may set if advertising set is active. + * + * @return Maximum advertising data length you may set if advertising set is active. + */ + virtual uint8_t getMaxActiveSetAdvertisingDataLength(); + /** Create an advertising set and apply the passed in parameters. The handle returned * by this function must be used for all other calls that accept an advertising handle. * When done with advertising, remove from the system using destroyAdvertisingSet(). @@ -589,6 +595,10 @@ public: * @param handle Advertising set handle. * @param payload Advertising payload. * + * @note If advertising set is active you may only set payload of length equal or less + * than getMaxActiveSetAdvertisingDataLength(). If you require a longer payload you must + * stop the advertising set, set the payload and restart the set. + * * @return BLE_ERROR_NONE on success. * * @see ble::AdvertisingDataBuilder to build a payload. @@ -604,6 +614,10 @@ public: * @param handle Advertising set handle. * @param response Advertising scan response. * + * @note If advertising set is active you may only set payload of length equal or less + * than getMaxActiveSetAdvertisingDataLength(). If you require a longer payload you must + * stop the advertising set, set the payload and restart the set. + * * @return BLE_ERROR_NONE on success. * * @see ble::AdvertisingDataBuilder to build a payload. @@ -669,6 +683,11 @@ public: * @param payload Advertising payload. * @return BLE_ERROR_NONE on success. * + * @note If advertising set is active you may only set payload of length equal or less + * than getMaxActiveSetAdvertisingDataLength(). If you require a longer payload you must + * stop the advertising set, set the payload and restart the set. Stopping the set will + * cause peers to lose sync on the periodic set. + * * @see ble::AdvertisingDataBuilder to build a payload. * * @version 5+ diff --git a/features/FEATURE_BLE/ble/generic/GenericGap.h b/features/FEATURE_BLE/ble/generic/GenericGap.h index 7ef9e66080..6ce595b53c 100644 --- a/features/FEATURE_BLE/ble/generic/GenericGap.h +++ b/features/FEATURE_BLE/ble/generic/GenericGap.h @@ -95,6 +95,10 @@ public: */ virtual uint16_t getMaxConnectableAdvertisingDataLength(); + /** @copydoc Gap::getMaxActiveSetAdvertisingDataLength + */ + virtual uint8_t getMaxActiveSetAdvertisingDataLength(); + /** @copydoc Gap::createAdvertisingSet */ virtual ble_error_t createAdvertisingSet( diff --git a/features/FEATURE_BLE/source/gap/Gap.cpp b/features/FEATURE_BLE/source/gap/Gap.cpp index 6a5d5d4cef..7b6f1dc02b 100644 --- a/features/FEATURE_BLE/source/gap/Gap.cpp +++ b/features/FEATURE_BLE/source/gap/Gap.cpp @@ -42,6 +42,12 @@ uint16_t Gap::getMaxConnectableAdvertisingDataLength() return LEGACY_ADVERTISING_MAX_SIZE; } +uint8_t Gap::getMaxActiveSetAdvertisingDataLength() +{ + /* Requesting action from porter(s): override this API if this capability is supported. */ + return LEGACY_ADVERTISING_MAX_SIZE; +} + ble_error_t Gap::createAdvertisingSet( advertising_handle_t *handle, const AdvertisingParameters ¶meters diff --git a/features/FEATURE_BLE/source/generic/GenericGap.cpp b/features/FEATURE_BLE/source/generic/GenericGap.cpp index c9bf963439..90c4fef464 100644 --- a/features/FEATURE_BLE/source/generic/GenericGap.cpp +++ b/features/FEATURE_BLE/source/generic/GenericGap.cpp @@ -2013,6 +2013,12 @@ uint16_t GenericGap::getMaxConnectableAdvertisingDataLength() return _pal_gap.get_maximum_connectable_advertising_data_length(); } +uint8_t GenericGap::getMaxActiveSetAdvertisingDataLength() +{ + useVersionTwoAPI(); + return _pal_gap.get_max_hci_advertising_data_length(); +} + ble_error_t GenericGap::createAdvertisingSet( advertising_handle_t *handle, const AdvertisingParameters ¶meters