Skip to content

Commit ba43f9d

Browse files
authored
ESP32: Fixes in BLEManager (#34082) (#34124)
- Fix the ble re-advertisement if invalid bytes are written on the characteristic. - cancel the ble advertisement timer on ble connection - remove the unnecessary if check
1 parent 13028cf commit ba43f9d

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/platform/ESP32/bluedroid/BLEManagerImpl.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ bool BLEManagerImpl::SendReadResponse(BLE_CONNECTION_OBJECT conId, BLE_READ_REQU
916916
void BLEManagerImpl::NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId)
917917
{
918918
ChipLogProgress(Ble, "Got notification regarding chip connection closure");
919+
CloseConnection(conId);
919920
}
920921

921922
CHIP_ERROR BLEManagerImpl::MapBLEError(int bleErr)

src/platform/ESP32/nimble/BLEManagerImpl.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,11 @@ bool BLEManagerImpl::SendReadResponse(BLE_CONNECTION_OBJECT conId, BLE_READ_REQU
674674
return false;
675675
}
676676

677-
void BLEManagerImpl::NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId) {}
677+
void BLEManagerImpl::NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId)
678+
{
679+
ChipLogDetail(Ble, "Received notification of closed CHIPoBLE connection (con %u)", conId);
680+
CloseConnection(conId);
681+
}
678682

679683
CHIP_ERROR BLEManagerImpl::MapBLEError(int bleErr)
680684
{
@@ -795,23 +799,19 @@ void BLEManagerImpl::DriveBLEState(void)
795799
ExitNow();
796800
}
797801
}
798-
// mFlags.Clear(Flags::kAdvertisingRefreshNeeded);
799802

800803
// Transition to the not Advertising state...
801-
if (mFlags.Has(Flags::kAdvertising))
802-
{
803-
mFlags.Clear(Flags::kAdvertising);
804-
mFlags.Set(Flags::kFastAdvertisingEnabled, true);
804+
mFlags.Clear(Flags::kAdvertising);
805+
mFlags.Set(Flags::kFastAdvertisingEnabled, true);
805806

806-
ChipLogProgress(DeviceLayer, "CHIPoBLE advertising stopped");
807+
ChipLogProgress(DeviceLayer, "CHIPoBLE advertising stopped");
807808

808-
// Post a CHIPoBLEAdvertisingChange(Stopped) event.
809-
{
810-
ChipDeviceEvent advChange;
811-
advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange;
812-
advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Stopped;
813-
err = PlatformMgr().PostEvent(&advChange);
814-
}
809+
// Post a CHIPoBLEAdvertisingChange(Stopped) event.
810+
{
811+
ChipDeviceEvent advChange;
812+
advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange;
813+
advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Stopped;
814+
err = PlatformMgr().PostEvent(&advChange);
815815
}
816816

817817
ExitNow();

0 commit comments

Comments
 (0)