Skip to content

Commit e737d56

Browse files
committed
GenericGap: prepare legacy advertising set
This is based on (and supercedes) PR ARMmbed#10772. As the switches between old and new APIs do not exist anymore, we create a function for legacy advertising set creation.
1 parent d320fc9 commit e737d56

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

features/FEATURE_BLE/ble/generic/GenericGap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,8 @@ class GenericGap :
831831
);
832832

833833
bool is_extended_advertising_available();
834+
835+
void prepare_legacy_advertising_set();
834836
};
835837

836838
} // namespace generic

features/FEATURE_BLE/source/generic/GenericGap.tpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,15 +1127,10 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
11271127

11281128
/* clear advertising set data on the controller */
11291129
_pal_gap.clear_advertising_sets();
1130-
1131-
setExtendedAdvertisingParameters(
1132-
LEGACY_ADVERTISING_HANDLE,
1133-
AdvertisingParameters()
1134-
);
11351130
#if BLE_FEATURE_EXTENDED_ADVERTISING
11361131
}
11371132

1138-
_existing_sets.set(LEGACY_ADVERTISING_HANDLE);
1133+
prepare_legacy_advertising_set();
11391134
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
11401135

11411136
return BLE_ERROR_NONE;
@@ -1844,6 +1839,8 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
18441839
return BLE_ERROR_INVALID_PARAM;
18451840
}
18461841

1842+
prepare_legacy_advertising_set();
1843+
18471844
if (!_existing_sets.get(handle)) {
18481845
return BLE_ERROR_INVALID_PARAM;
18491846
}
@@ -1998,6 +1995,8 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
19981995
return BLE_ERROR_INVALID_PARAM;
19991996
}
20001997

1998+
prepare_legacy_advertising_set();
1999+
20012000
if (!_existing_sets.get(handle)) {
20022001
return BLE_ERROR_INVALID_PARAM;
20032002
}
@@ -2902,5 +2901,22 @@ bool GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
29022901
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
29032902
}
29042903

2904+
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
2905+
void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::prepare_legacy_advertising_set()
2906+
{
2907+
#if BLE_FEATURE_EXTENDED_ADVERTISING
2908+
if (_existing_sets.get(LEGACY_ADVERTISING_HANDLE)) {
2909+
return;
2910+
}
2911+
2912+
setExtendedAdvertisingParameters(
2913+
LEGACY_ADVERTISING_HANDLE,
2914+
AdvertisingParameters()
2915+
);
2916+
_existing_sets.set(LEGACY_ADVERTISING_HANDLE);
2917+
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
2918+
}
2919+
2920+
29052921
} // generic
29062922
} // ble

0 commit comments

Comments
 (0)