@@ -140,6 +140,8 @@ const ble_uuid128_t UUID_CHIPoBLEChar_C3 = {
140140};
141141#endif // CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
142142
143+ const struct ble_gatt_svc_def kNullSvc = { 0 };
144+
143145SemaphoreHandle_t semaphoreHandle = NULL ;
144146
145147// LE Random Device Address
@@ -152,7 +154,7 @@ uint8_t own_addr_type = BLE_OWN_ADDR_RANDOM;
152154ChipDeviceScanner & mDeviceScanner = Internal::ChipDeviceScanner::GetInstance();
153155#endif
154156BLEManagerImpl BLEManagerImpl::sInstance ;
155- const struct ble_gatt_svc_def BLEManagerImpl::CHIPoBLEGATTAttrs[] = {
157+ const struct ble_gatt_svc_def BLEManagerImpl::CHIPoBLEGATTSvc =
156158 { .type = BLE_GATT_SVC_TYPE_PRIMARY,
157159 .uuid = (ble_uuid_t *) (&ShortUUID_CHIPoBLEService),
158160 .characteristics =
@@ -180,11 +182,7 @@ const struct ble_gatt_svc_def BLEManagerImpl::CHIPoBLEGATTAttrs[] = {
180182 {
181183 0 , /* No more characteristics in this service */
182184 },
183- } },
184-
185- {
186- 0 , /* No more services. */
187- },
185+ }
188186};
189187
190188#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER
@@ -261,7 +259,7 @@ CHIP_ERROR BLEManagerImpl::_Init()
261259 mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled ;
262260 memset (mDeviceName , 0 , sizeof (mDeviceName ));
263261
264- PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
262+ TEMPORARY_RETURN_IGNORED PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
265263
266264exit:
267265 return err;
@@ -277,7 +275,7 @@ void BLEManagerImpl::_Shutdown()
277275 mFlags .ClearAll ().Set (Flags::kGATTServiceStarted );
278276 mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Disabled ;
279277
280- PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
278+ TEMPORARY_RETURN_IGNORED PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
281279}
282280
283281CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled (bool val)
@@ -294,7 +292,7 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val)
294292 mFlags .Set (Flags::kFastAdvertisingEnabled , val);
295293 mFlags .Set (Flags::kAdvertisingRefreshNeeded , 1 );
296294 mFlags .Set (Flags::kAdvertisingEnabled , val);
297- PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
295+ TEMPORARY_RETURN_IGNORED PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
298296
299297exit:
300298 return err;
@@ -323,7 +321,7 @@ void BLEManagerImpl::BleAdvTimeoutHandler(System::Layer *, void *)
323321 BLEMgrImpl ().mFlags .Set (Flags::kAdvertisingRefreshNeeded , 1 );
324322 }
325323#endif
326- PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
324+ TEMPORARY_RETURN_IGNORED PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
327325}
328326
329327CHIP_ERROR BLEManagerImpl::_SetAdvertisingMode (BLEAdvertisingMode mode)
@@ -340,7 +338,7 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingMode(BLEAdvertisingMode mode)
340338 return CHIP_ERROR_INVALID_ARGUMENT;
341339 }
342340 mFlags .Set (Flags::kAdvertisingRefreshNeeded );
343- PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
341+ TEMPORARY_RETURN_IGNORED PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
344342 return CHIP_NO_ERROR;
345343}
346344
@@ -606,7 +604,7 @@ CHIP_ERROR BLEManagerImpl::CloseConnection(BLE_CONNECTION_OBJECT conId)
606604 // Force a refresh of the advertising state.
607605 mFlags .Set (Flags::kAdvertisingRefreshNeeded );
608606 mFlags .Clear (Flags::kAdvertisingConfigured );
609- PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
607+ TEMPORARY_RETURN_IGNORED PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
610608#endif
611609
612610 return err;
@@ -705,7 +703,7 @@ CHIP_ERROR BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const C
705703void BLEManagerImpl::NotifyChipConnectionClosed (BLE_CONNECTION_OBJECT conId)
706704{
707705 ChipLogDetail (Ble, " Received notification of closed CHIPoBLE connection (con %u)" , conId);
708- CloseConnection (conId);
706+ TEMPORARY_RETURN_IGNORED CloseConnection (conId);
709707}
710708
711709CHIP_ERROR BLEManagerImpl::MapBLEError (int bleErr)
@@ -1006,14 +1004,19 @@ CHIP_ERROR BLEManagerImpl::InitESPBleLayer(void)
10061004 ble_svc_gap_init ();
10071005 ble_svc_gatt_init ();
10081006
1009- err = MapBLEError (ble_gatts_count_cfg (CHIPoBLEGATTAttrs));
1007+ if (mGattSvcs .size () == 0 )
1008+ {
1009+ mGattSvcs .push_back (CHIPoBLEGATTSvc);
1010+ mGattSvcs .push_back (kNullSvc );
1011+ }
1012+ err = MapBLEError (ble_gatts_count_cfg (&mGattSvcs [0 ]));
10101013 if (err != CHIP_NO_ERROR)
10111014 {
10121015 ChipLogError (DeviceLayer, " ble_gatts_count_cfg failed: %s" , ErrorStr (err));
10131016 ExitNow ();
10141017 }
10151018
1016- err = MapBLEError (ble_gatts_add_svcs (CHIPoBLEGATTAttrs ));
1019+ err = MapBLEError (ble_gatts_add_svcs (& mGattSvcs [ 0 ] ));
10171020 if (err != CHIP_NO_ERROR)
10181021 {
10191022 ChipLogError (DeviceLayer, " ble_gatts_add_svcs failed: %s" , ErrorStr (err));
@@ -1616,7 +1619,7 @@ int BLEManagerImpl::ble_svr_gap_event(struct ble_gap_event * event, void * arg)
16161619 {
16171620#endif
16181621 // Schedule DriveBLEState() to run.
1619- PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
1622+ TEMPORARY_RETURN_IGNORED PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
16201623#if CONFIG_BLE_MESH
16211624 }
16221625#endif
@@ -1683,7 +1686,7 @@ int BLEManagerImpl::gatt_svr_chr_access_additional_data(uint16_t conn_handle, ui
16831686 break ;
16841687 }
16851688
1686- PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
1689+ TEMPORARY_RETURN_IGNORED PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
16871690
16881691 return err;
16891692}
@@ -1729,7 +1732,7 @@ int BLEManagerImpl::gatt_svr_chr_access(uint16_t conn_handle, uint16_t attr_hand
17291732 break ;
17301733 }
17311734
1732- PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
1735+ TEMPORARY_RETURN_IGNORED PlatformMgr ().ScheduleWork (DriveBLEState, 0 );
17331736
17341737 return err;
17351738}
@@ -2010,7 +2013,7 @@ void BLEManagerImpl::NewConnection(BleLayer * bleLayer, void * appState, const S
20102013 mBLEScanConfig .mAppState = appState;
20112014
20122015 // Initiate async scan
2013- PlatformMgr ().ScheduleWork (InitiateScan, static_cast <intptr_t >(BleScanState::kScanForDiscriminator ));
2016+ TEMPORARY_RETURN_IGNORED PlatformMgr ().ScheduleWork (InitiateScan, static_cast <intptr_t >(BleScanState::kScanForDiscriminator ));
20142017}
20152018
20162019CHIP_ERROR BLEManagerImpl::CancelConnection ()
0 commit comments