Skip to content

Commit c5bad80

Browse files
add asserts for illegal compinations of adv params
1 parent 7dd90e1 commit c5bad80

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

features/FEATURE_BLE/ble/gap/AdvertisingParameters.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ class AdvertisingParameters {
174174
*/
175175
AdvertisingParameters &setType(advertising_type_t newAdvType)
176176
{
177+
if (newAdvType == advertising_type_t::CONNECTABLE_UNDIRECTED ||
178+
newAdvType == advertising_type_t::CONNECTABLE_DIRECTED) {
179+
/* these types can only be used with legacy PDUs */
180+
MBED_ASSERT(_legacyPDU);
181+
}
177182
_advType = newAdvType;
178183
return *this;
179184
}
@@ -461,6 +466,12 @@ class AdvertisingParameters {
461466
*/
462467
AdvertisingParameters &setUseLegacyPDU(bool enable = true)
463468
{
469+
if (!enable) {
470+
/* these types can only be used with legacy PDUs */
471+
MBED_ASSERT((_advType != advertising_type_t::CONNECTABLE_UNDIRECTED) &&
472+
(_advType != advertising_type_t::CONNECTABLE_DIRECTED));
473+
}
474+
464475
_legacyPDU = enable;
465476
return *this;
466477
}

0 commit comments

Comments
 (0)