Skip to content

Commit

Permalink
Forward BLE disconnection to CHIPoBLE layer
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Jun 7, 2024
1 parent 55a1d46 commit 2ff6dac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/platform/Tizen/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,16 +401,16 @@ void BLEManagerImpl::NotifyBLEIndicationConfirmation(BLE_CONNECTION_OBJECT conId
PlatformMgr().PostEventOrDie(&event);
}

void BLEManagerImpl::NotifyBLEConnectionEstablished(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error)
void BLEManagerImpl::NotifyBLEConnectionEstablished(BLE_CONNECTION_OBJECT conId)
{
ChipDeviceEvent event{ .Type = DeviceEventType::kCHIPoBLEConnectionEstablished };
PlatformMgr().PostEventOrDie(&event);
}

void BLEManagerImpl::NotifyBLEDisconnection(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error)
void BLEManagerImpl::NotifyBLEDisconnection(BLE_CONNECTION_OBJECT conId)
{
ChipDeviceEvent event{ .Type = DeviceEventType::kCHIPoBLEConnectionError,
.CHIPoBLEConnectionError = { .ConId = conId, .Reason = error } };
.CHIPoBLEConnectionError = { .ConId = conId, .Reason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED } };
PlatformMgr().PostEventOrDie(&event);
}

Expand Down Expand Up @@ -873,6 +873,7 @@ void BLEManagerImpl::RemoveConnectionData(const char * remoteAddr)
VerifyOrReturn(conn != nullptr,
ChipLogError(DeviceLayer, "Connection does not exist for [%s]", StringOrNullMarker(remoteAddr)));

BLEManagerImpl::NotifyBLEDisconnection(conn);
g_hash_table_remove(mConnectionMap, remoteAddr);

ChipLogProgress(DeviceLayer, "Connection Removed");
Expand Down Expand Up @@ -925,7 +926,7 @@ void BLEManagerImpl::HandleConnectionEvent(bool connected, const char * remoteAd
}
else
{
ChipLogProgress(DeviceLayer, "Device DisConnected [%s]", StringOrNullMarker(remoteAddress));
ChipLogProgress(DeviceLayer, "Device Disconnected [%s]", StringOrNullMarker(remoteAddress));
RemoveConnectionData(remoteAddress);
}
}
Expand Down Expand Up @@ -1160,7 +1161,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
ChipLogProgress(DeviceLayer, "CHIPoBLESubscribe");

HandleSubscribeReceived(event->CHIPoBLESubscribe.ConId, &Ble::CHIP_BLE_SVC_ID, &Ble::CHIP_BLE_CHAR_2_UUID);
NotifyBLEConnectionEstablished(event->CHIPoBLESubscribe.ConId, CHIP_NO_ERROR);
NotifyBLEConnectionEstablished(event->CHIPoBLESubscribe.ConId);
break;
case DeviceEventType::kCHIPoBLEUnsubscribe:
ChipLogProgress(DeviceLayer, "CHIPoBLEUnsubscribe");
Expand Down
4 changes: 2 additions & 2 deletions src/platform/Tizen/BLEManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ class BLEManagerImpl final : public BLEManager,

// ==== Connection.
CHIP_ERROR ConnectChipThing(const char * address);
void NotifyBLEConnectionEstablished(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error);
void NotifyBLEDisconnection(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error);
void NotifyBLEConnectionEstablished(BLE_CONNECTION_OBJECT conId);
void NotifyBLEDisconnection(BLE_CONNECTION_OBJECT conId);
void NotifyHandleNewConnection(BLE_CONNECTION_OBJECT conId);
void NotifyHandleConnectFailed(CHIP_ERROR error);
void NotifyHandleWriteComplete(BLE_CONNECTION_OBJECT conId);
Expand Down

0 comments on commit 2ff6dac

Please sign in to comment.