@@ -1096,11 +1096,10 @@ ble_error_t Gap::reset()
10961096#endif
10971097
10981098#if BLE_ROLE_BROADCASTER
1099- _advertising_timeout.detach ();
11001099#if BLE_FEATURE_EXTENDED_ADVERTISING
11011100 if (is_extended_advertising_available ()) {
11021101 /* stop all advertising sets */
1103- for (size_t i = 1 ; i < BLE_GAP_MAX_ADVERTISING_SETS; ++i) {
1102+ for (size_t i = 0 ; i < BLE_GAP_MAX_ADVERTISING_SETS; ++i) {
11041103 if (_active_sets.get (i)) {
11051104 _pal_gap.extended_advertising_enable (
11061105 /* enable */ false ,
@@ -1117,40 +1116,31 @@ ble_error_t Gap::reset()
11171116 (advertising_handle_t ) i
11181117 );
11191118 }
1119+ _active_periodic_sets.clear ();
11201120#endif // BLE_FEATURE_PERIODIC_ADVERTISING
11211121 }
11221122
11231123 /* clear state of all advertising sets */
11241124 _existing_sets.clear ();
1125- #endif // BLE_FEATURE_EXTENDED_ADVERTISING
1126- #if BLE_FEATURE_PERIODIC_ADVERTISING
1127- _active_periodic_sets.clear ();
1128- #endif
1129- if (_active_sets.get (LEGACY_ADVERTISING_HANDLE)) {
1130- #if BLE_FEATURE_EXTENDED_ADVERTISING
1131- _pal_gap.extended_advertising_enable (
1132- /* enable */ false ,
1133- /* number of advertising sets */ 1 ,
1134- (advertising_handle_t *) &LEGACY_ADVERTISING_HANDLE,
1135- nullptr ,
1136- nullptr
1137- );
1138- #else
1139- _pal_gap.advertising_enable (false );
1140- #endif
1141- }
1142- _active_sets.clear ();
1143- _pending_sets.clear ();
1144- _address_refresh_sets.clear ();
1145- _interruptible_sets.clear ();
1146- _connectable_payload_size_exceeded.clear ();
1147- _set_is_connectable.clear ();
11481125
1149- #if BLE_FEATURE_EXTENDED_ADVERTISING
11501126 /* clear advertising set data on the controller */
11511127 _pal_gap.clear_advertising_sets ();
1128+ } else
1129+ #else // BLE_FEATURE_EXTENDED_ADVERTISING
1130+ {
1131+ if (_active_sets.get (LEGACY_ADVERTISING_HANDLE)) {
1132+ _pal_gap.advertising_enable (false );
1133+ }
11521134 }
11531135#endif // BLE_FEATURE_EXTENDED_ADVERTISING
1136+
1137+ _active_sets.clear ();
1138+ _pending_sets.clear ();
1139+ _address_refresh_sets.clear ();
1140+ _interruptible_sets.clear ();
1141+ _connectable_payload_size_exceeded.clear ();
1142+ _set_is_connectable.clear ();
1143+ _advertising_timeout.detach ();
11541144#endif // #BLE_ROLE_BROADCASTER
11551145
11561146 return BLE_ERROR_NONE;
0 commit comments