From 5bc6767e5b19b454de4b3505b3a32c673a4d217c Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Wed, 5 Jun 2024 15:19:14 +0200 Subject: [PATCH] [Tizen] Allow to pass CHIP error to device event (#33744) * Create GATT service with short Bluetooth SIG UUID * Do not initialize characteristics with dummy values * Do not keep non-Matter UUIDs in BleUUID.h * Pass CHIP_ERROR to device event * Simplify ChipDeviceEvent initialization * Restyled by clang-format --------- Co-authored-by: Restyled.io --- src/ble/BleUUID.h | 1 - src/platform/Linux/CHIPDevicePlatformEvent.h | 1 + src/platform/Tizen/BLEManagerImpl.cpp | 139 +++++++++---------- src/platform/Tizen/BLEManagerImpl.h | 14 +- src/platform/Tizen/CHIPDevicePlatformEvent.h | 13 +- 5 files changed, 75 insertions(+), 93 deletions(-) diff --git a/src/ble/BleUUID.h b/src/ble/BleUUID.h index 37e2fdc1180f5e..1c0eefd514100a 100644 --- a/src/ble/BleUUID.h +++ b/src/ble/BleUUID.h @@ -101,7 +101,6 @@ constexpr std::pair StringToUUID(const char (&str)[N]) // BlueZ API https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/org.bluez.Device.rst // describes ServiceData as "Keys are the UUIDs in string format" however no description // on actual case required -inline constexpr char CHIP_BLE_DESC_SHORT_UUID_STR[] = "2902"; inline constexpr char CHIP_BLE_SERVICE_SHORT_UUID_STR[] = "fff6"; inline constexpr char CHIP_BLE_SERVICE_LONG_UUID_STR[] = "0000fff6-0000-1000-8000-00805f9b34fb"; inline constexpr char CHIP_BLE_CHAR_1_UUID_STR[] = "18ee2ef5-263d-4559-959f-4f9c429f9d11"; diff --git a/src/platform/Linux/CHIPDevicePlatformEvent.h b/src/platform/Linux/CHIPDevicePlatformEvent.h index 18ed55a1ef28d4..a70411888413c1 100644 --- a/src/platform/Linux/CHIPDevicePlatformEvent.h +++ b/src/platform/Linux/CHIPDevicePlatformEvent.h @@ -23,6 +23,7 @@ #pragma once +#include #include #include diff --git a/src/platform/Tizen/BLEManagerImpl.cpp b/src/platform/Tizen/BLEManagerImpl.cpp index 209c5fb2337356..247719a9199b76 100644 --- a/src/platform/Tizen/BLEManagerImpl.cpp +++ b/src/platform/Tizen/BLEManagerImpl.cpp @@ -74,6 +74,9 @@ namespace Internal { namespace { +// Bluetooth SIG defined UUID for Client Characteristic Configuration Descriptor +constexpr const char * kClientCharacteristicConfigurationUUID = "2902"; + constexpr System::Clock::Timeout kNewConnectionScanTimeout = System::Clock::Seconds16(20); constexpr System::Clock::Timeout kConnectTimeout = System::Clock::Seconds16(20); constexpr System::Clock::Timeout kFastAdvertiseTimeout = @@ -208,7 +211,10 @@ void BLEManagerImpl::ReadValueRequestedCb(const char * remoteAddress, int reques ChipLogByteSpan(DeviceLayer, ByteSpan(Uint8::from_const_char(value.get()), len)); - ret = bt_gatt_server_send_response(requestId, BT_GATT_REQUEST_TYPE_READ, offset, 0x00, value.get(), len); + char dummyValue[] = ""; + // Tizen API does not like NULLs even for zero-length values. + char * valuePtr = value ? value.get() : dummyValue; + ret = bt_gatt_server_send_response(requestId, BT_GATT_REQUEST_TYPE_READ, offset, BT_ATT_ERROR_NONE, valuePtr, len); VerifyOrReturn(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_server_send_response() failed: %s", get_error_message(ret))); } @@ -233,7 +239,7 @@ void BLEManagerImpl::WriteValueRequestedCb(const char * remoteAddress, int reque ret = bt_gatt_set_value(gattHandle, value, len); VerifyOrReturn(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_set_value() failed: %s", get_error_message(ret))); - ret = bt_gatt_server_send_response(requestId, BT_GATT_REQUEST_TYPE_WRITE, offset, 0x00, nullptr, 0); + ret = bt_gatt_server_send_response(requestId, BT_GATT_REQUEST_TYPE_WRITE, offset, BT_ATT_ERROR_NONE, nullptr, 0); VerifyOrReturn(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_server_send_response() failed: %s", get_error_message(ret))); @@ -265,7 +271,7 @@ void BLEManagerImpl::NotificationStateChangedCb(bool notify, bt_gatt_server_h se ChipLogProgress(DeviceLayer, "Notification State Changed %d on %s: %s", notify, __ConvertAttTypeToStr(type), StringOrNullMarker(uuid.get())); - NotifyBLESubscribed(notify ? true : false, conn); + NotifyBLESubscribed(conn, notify ? true : false); } void BLEManagerImpl::WriteCompletedCb(int result, bt_gatt_h gattHandle, void * userData) @@ -314,7 +320,7 @@ void BLEManagerImpl::AdvertisingStateChangedCb(int result, bt_advertiser_h adver if (advState == BT_ADAPTER_LE_ADVERTISING_STARTED) { mFlags.Set(Flags::kAdvertising); - NotifyBLEPeripheralAdvStartComplete(true, nullptr); + NotifyBLEPeripheralAdvStartComplete(CHIP_NO_ERROR); DeviceLayer::SystemLayer().ScheduleLambda([this] { // Start a timer to make sure that the fast advertising is stopped after specified timeout. DeviceLayer::SystemLayer().StartTimer(kFastAdvertiseTimeout, HandleAdvertisingTimeout, this); @@ -323,7 +329,7 @@ void BLEManagerImpl::AdvertisingStateChangedCb(int result, bt_advertiser_h adver else { mFlags.Clear(Flags::kAdvertising); - NotifyBLEPeripheralAdvStopComplete(true, nullptr); + NotifyBLEPeripheralAdvStopComplete(CHIP_NO_ERROR); DeviceLayer::SystemLayer().ScheduleLambda( [this] { DeviceLayer::SystemLayer().CancelTimer(HandleAdvertisingTimeout, this); }); } @@ -338,89 +344,73 @@ void BLEManagerImpl::AdvertisingStateChangedCb(int result, bt_advertiser_h adver } // ====== Private Functions. -void BLEManagerImpl::NotifyBLEPeripheralGATTServerRegisterComplete(bool aIsSuccess, void * apAppstate) + +void BLEManagerImpl::NotifyBLEPeripheralGATTServerRegisterComplete(CHIP_ERROR error) { - ChipDeviceEvent event; - event.Type = DeviceEventType::kPlatformTizenBLEPeripheralGATTServerRegisterComplete; - event.Platform.BLEPeripheralGATTServerRegisterComplete.mIsSuccess = aIsSuccess; - event.Platform.BLEPeripheralGATTServerRegisterComplete.mpAppstate = apAppstate; + ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformTizenBLEPeripheralGATTServerRegisterComplete, + .Platform = { .BLEPeripheralGATTServerRegisterComplete = { .mError = error } } }; PlatformMgr().PostEventOrDie(&event); } -void BLEManagerImpl::NotifyBLEPeripheralAdvConfiguredComplete(bool aIsSuccess, void * apAppstate) +void BLEManagerImpl::NotifyBLEPeripheralAdvConfiguredComplete(CHIP_ERROR error) { - ChipDeviceEvent event; - event.Type = DeviceEventType::kPlatformTizenBLEPeripheralAdvConfiguredComplete; - event.Platform.BLEPeripheralAdvConfiguredComplete.mIsSuccess = aIsSuccess; - event.Platform.BLEPeripheralAdvConfiguredComplete.mpAppstate = apAppstate; + ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformTizenBLEPeripheralAdvConfiguredComplete, + .Platform = { .BLEPeripheralAdvConfiguredComplete = { .mError = error } } }; PlatformMgr().PostEventOrDie(&event); } -void BLEManagerImpl::NotifyBLEPeripheralAdvStartComplete(bool aIsSuccess, void * apAppstate) +void BLEManagerImpl::NotifyBLEPeripheralAdvStartComplete(CHIP_ERROR error) { - ChipDeviceEvent event; - event.Type = DeviceEventType::kPlatformTizenBLEPeripheralAdvStartComplete; - event.Platform.BLEPeripheralAdvStartComplete.mIsSuccess = aIsSuccess; - event.Platform.BLEPeripheralAdvStartComplete.mpAppstate = apAppstate; + ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformTizenBLEPeripheralAdvStartComplete, + .Platform = { .BLEPeripheralAdvStartComplete = { .mError = error } } }; PlatformMgr().PostEventOrDie(&event); } -void BLEManagerImpl::NotifyBLEPeripheralAdvStopComplete(bool aIsSuccess, void * apAppstate) +void BLEManagerImpl::NotifyBLEPeripheralAdvStopComplete(CHIP_ERROR error) { - ChipDeviceEvent event; - event.Type = DeviceEventType::kPlatformTizenBLEPeripheralAdvStopComplete; - event.Platform.BLEPeripheralAdvStopComplete.mIsSuccess = aIsSuccess; - event.Platform.BLEPeripheralAdvStopComplete.mpAppstate = apAppstate; + ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformTizenBLEPeripheralAdvStopComplete, + .Platform = { .BLEPeripheralAdvStopComplete = { .mError = error } } }; PlatformMgr().PostEventOrDie(&event); } -void BLEManagerImpl::NotifyBLEWriteReceived(System::PacketBufferHandle & buf, BLE_CONNECTION_OBJECT conId) +void BLEManagerImpl::NotifyBLEWriteReceived(BLE_CONNECTION_OBJECT conId, System::PacketBufferHandle & buf) { - ChipDeviceEvent event; - event.Type = DeviceEventType::kCHIPoBLEWriteReceived; - event.CHIPoBLEWriteReceived.ConId = conId; - event.CHIPoBLEWriteReceived.Data = std::move(buf).UnsafeRelease(); + ChipDeviceEvent event{ .Type = DeviceEventType::kCHIPoBLEWriteReceived, + .CHIPoBLEWriteReceived = { .ConId = conId, .Data = std::move(buf).UnsafeRelease() } }; PlatformMgr().PostEventOrDie(&event); } -void BLEManagerImpl::NotifyBLENotificationReceived(System::PacketBufferHandle & buf, BLE_CONNECTION_OBJECT conId) +void BLEManagerImpl::NotifyBLENotificationReceived(BLE_CONNECTION_OBJECT conId, System::PacketBufferHandle & buf) { - ChipDeviceEvent event; - event.Type = DeviceEventType::kPlatformTizenBLEIndicationReceived; - event.Platform.BLEIndicationReceived.mConnection = conId; - event.Platform.BLEIndicationReceived.mData = std::move(buf).UnsafeRelease(); + ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformTizenBLEIndicationReceived, + .Platform = { + .BLEIndicationReceived = { .mConnection = conId, .mData = std::move(buf).UnsafeRelease() } } }; PlatformMgr().PostEventOrDie(&event); } -void BLEManagerImpl::NotifyBLESubscribed(bool indicationsEnabled, BLE_CONNECTION_OBJECT conId) +void BLEManagerImpl::NotifyBLESubscribed(BLE_CONNECTION_OBJECT conId, bool indicationsEnabled) { - ChipDeviceEvent event; - event.Type = (indicationsEnabled) ? DeviceEventType::kCHIPoBLESubscribe : DeviceEventType::kCHIPoBLEUnsubscribe; - event.CHIPoBLESubscribe.ConId = conId; + ChipDeviceEvent event{ .Type = indicationsEnabled ? DeviceEventType::kCHIPoBLESubscribe : DeviceEventType::kCHIPoBLEUnsubscribe, + .CHIPoBLESubscribe = { .ConId = conId } }; PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::NotifyBLEIndicationConfirmation(BLE_CONNECTION_OBJECT conId) { - ChipDeviceEvent event; - event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; - event.CHIPoBLEIndicateConfirm.ConId = conId; + ChipDeviceEvent event{ .Type = DeviceEventType::kCHIPoBLEIndicateConfirm, .CHIPoBLEIndicateConfirm = { .ConId = conId } }; PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::NotifyBLEConnectionEstablished(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error) { - ChipDeviceEvent event; - event.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; + ChipDeviceEvent event{ .Type = DeviceEventType::kCHIPoBLEConnectionEstablished }; PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::NotifyBLEDisconnection(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error) { - ChipDeviceEvent event; - event.Type = DeviceEventType::kCHIPoBLEConnectionError; - event.CHIPoBLEConnectionError.ConId = conId; - event.CHIPoBLEConnectionError.Reason = error; + ChipDeviceEvent event{ .Type = DeviceEventType::kCHIPoBLEConnectionError, + .CHIPoBLEConnectionError = { .ConId = conId, .Reason = error } }; PlatformMgr().PostEventOrDie(&event); } @@ -429,9 +419,8 @@ void BLEManagerImpl::NotifyHandleConnectFailed(CHIP_ERROR error) ChipLogProgress(DeviceLayer, "Connection failed: %" CHIP_ERROR_FORMAT, error.Format()); if (mIsCentral) { - ChipDeviceEvent event; - event.Type = DeviceEventType::kPlatformTizenBLECentralConnectFailed; - event.Platform.BLECentralConnectFailed.mError = error; + ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformTizenBLECentralConnectFailed, + .Platform = { .BLECentralConnectFailed = { .mError = error } } }; PlatformMgr().PostEventOrDie(&event); } } @@ -440,27 +429,23 @@ void BLEManagerImpl::NotifyHandleNewConnection(BLE_CONNECTION_OBJECT conId) { if (mIsCentral) { - ChipDeviceEvent event; - event.Type = DeviceEventType::kPlatformTizenBLECentralConnected; - event.Platform.BLECentralConnected.mConnection = conId; + ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformTizenBLECentralConnected, + .Platform = { .BLECentralConnected = { .mConnection = conId } } }; PlatformMgr().PostEventOrDie(&event); } } void BLEManagerImpl::NotifyHandleWriteComplete(BLE_CONNECTION_OBJECT conId) { - ChipDeviceEvent event; - event.Type = DeviceEventType::kPlatformTizenBLEWriteComplete; - event.Platform.BLEWriteComplete.mConnection = conId; + ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformTizenBLEWriteComplete, + .Platform = { .BLEWriteComplete = { .mConnection = conId } } }; PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::NotifySubscribeOpComplete(BLE_CONNECTION_OBJECT conId, bool isSubscribed) { - ChipDeviceEvent event; - event.Type = DeviceEventType::kPlatformTizenBLESubscribeOpComplete; - event.Platform.BLESubscribeOpComplete.mConnection = conId; - event.Platform.BLESubscribeOpComplete.mIsSubscribed = isSubscribed; + ChipDeviceEvent event{ .Type = DeviceEventType::kPlatformTizenBLESubscribeOpComplete, + .Platform = { .BLESubscribeOpComplete = { .mConnection = conId, .mIsSubscribed = isSubscribed } } }; PlatformMgr().PostEventOrDie(&event); } @@ -574,7 +559,7 @@ CHIP_ERROR BLEManagerImpl::RegisterGATTServer() VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_server_create() failed: %s", get_error_message(ret))); // Create Service (BTP Service) - ret = bt_gatt_service_create(Ble::CHIP_BLE_SERVICE_LONG_UUID_STR, BT_GATT_SERVICE_TYPE_PRIMARY, &service); + ret = bt_gatt_service_create(Ble::CHIP_BLE_SERVICE_SHORT_UUID_STR, BT_GATT_SERVICE_TYPE_PRIMARY, &service); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_service_create() failed: %s", get_error_message(ret))); // Create 1st Characteristic (Client TX Buffer) @@ -583,7 +568,7 @@ CHIP_ERROR BLEManagerImpl::RegisterGATTServer() BT_GATT_PROPERTY_WRITE, // Write Request is not coming if we use WITHOUT_RESPONSE property. Let's use WRITE property and // consider to use WITHOUT_RESPONSE property in the future according to the CHIP Spec 4.16.3.2. BTP // GATT Service - "CHIPoBLE_C1", strlen("CHIPoBLE_C1"), &char1); + nullptr, 0, &char1); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_characteristic_create() failed: %s", get_error_message(ret))); @@ -604,8 +589,7 @@ CHIP_ERROR BLEManagerImpl::RegisterGATTServer() // Create 2nd Characteristic (Client RX Buffer) ret = bt_gatt_characteristic_create(Ble::CHIP_BLE_CHAR_2_UUID_STR, BT_GATT_PERMISSION_READ, - BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_INDICATE, "CHIPoBLE_C2", strlen("CHIPoBLE_C2"), - &char2); + BT_GATT_PROPERTY_READ | BT_GATT_PROPERTY_INDICATE, nullptr, 0, &char2); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_characteristic_create() failed: %s", get_error_message(ret))); @@ -618,6 +602,7 @@ CHIP_ERROR BLEManagerImpl::RegisterGATTServer() this); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_server_set_read_value_requested_cb() failed: %s", get_error_message(ret))); + ret = bt_gatt_server_set_characteristic_notification_state_change_cb( char2, +[](bool notify, bt_gatt_server_h gattServer, bt_gatt_h charHandle, void * self) { @@ -628,13 +613,14 @@ CHIP_ERROR BLEManagerImpl::RegisterGATTServer() ChipLogError(DeviceLayer, "bt_gatt_server_set_characteristic_notification_state_change_cb() failed: %s", get_error_message(ret))); - // Create CCC Descriptor - ret = bt_gatt_descriptor_create(Ble::CHIP_BLE_DESC_SHORT_UUID_STR, BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE, + ret = bt_gatt_descriptor_create(kClientCharacteristicConfigurationUUID, BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE, desc_value, sizeof(desc_value), &desc); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_descriptor_create() failed: %s", get_error_message(ret))); + ret = bt_gatt_characteristic_add_descriptor(char2, desc); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_characteristic_add_descriptor() failed: %s", get_error_message(ret))); + ret = bt_gatt_service_add_characteristic(service, char2); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_service_add_characteristic() failed: %s", get_error_message(ret))); @@ -648,8 +634,7 @@ CHIP_ERROR BLEManagerImpl::RegisterGATTServer() ret = bt_gatt_server_start(); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_server_start() failed: %s", get_error_message(ret))); - ChipLogDetail(DeviceLayer, "NotifyBLEPeripheralGATTServerRegisterComplete Success"); - BLEManagerImpl::NotifyBLEPeripheralGATTServerRegisterComplete(true, nullptr); + BLEManagerImpl::NotifyBLEPeripheralGATTServerRegisterComplete(CHIP_NO_ERROR); // Save the Local Peripheral char1 & char2 handles mGattCharC1Handle = char1; @@ -657,8 +642,7 @@ CHIP_ERROR BLEManagerImpl::RegisterGATTServer() return CHIP_NO_ERROR; exit: - ChipLogDetail(DeviceLayer, "NotifyBLEPeripheralGATTServerRegisterComplete Failed"); - BLEManagerImpl::NotifyBLEPeripheralGATTServerRegisterComplete(false, nullptr); + BLEManagerImpl::NotifyBLEPeripheralGATTServerRegisterComplete(TizenToChipError(ret)); return TizenToChipError(ret); } @@ -727,7 +711,7 @@ CHIP_ERROR BLEManagerImpl::StartBLEAdvertising() VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_adapter_le_set_advertising_device_name() failed: %s", get_error_message(ret))); - BLEManagerImpl::NotifyBLEPeripheralAdvConfiguredComplete(true, nullptr); + BLEManagerImpl::NotifyBLEPeripheralAdvConfiguredComplete(CHIP_NO_ERROR); ret = bt_adapter_le_start_advertising_new( mAdvertiser, @@ -742,8 +726,9 @@ CHIP_ERROR BLEManagerImpl::StartBLEAdvertising() return CHIP_NO_ERROR; exit: - BLEManagerImpl::NotifyBLEPeripheralAdvStartComplete(false, nullptr); - return ret != BT_ERROR_NONE ? TizenToChipError(ret) : err; + err = ret != BT_ERROR_NONE ? TizenToChipError(ret) : err; + BLEManagerImpl::NotifyBLEPeripheralAdvStartComplete(err); + return err; } CHIP_ERROR BLEManagerImpl::StopBLEAdvertising() @@ -758,7 +743,7 @@ CHIP_ERROR BLEManagerImpl::StopBLEAdvertising() return CHIP_NO_ERROR; exit: - BLEManagerImpl::NotifyBLEPeripheralAdvStopComplete(false, nullptr); + BLEManagerImpl::NotifyBLEPeripheralAdvStopComplete(TizenToChipError(ret)); return TizenToChipError(ret); } @@ -896,7 +881,7 @@ void BLEManagerImpl::HandleC1CharWriteEvent(BLE_CONNECTION_OBJECT conId, const u // Copy the data to a packet buffer. buf = System::PacketBufferHandle::NewWithData(value, len); VerifyOrExit(!buf.IsNull(), err = CHIP_ERROR_NO_MEMORY); - NotifyBLEWriteReceived(buf, conId); + NotifyBLEWriteReceived(conId, buf); return; exit: if (err != CHIP_NO_ERROR) @@ -915,7 +900,7 @@ void BLEManagerImpl::HandleRXCharChanged(BLE_CONNECTION_OBJECT conId, const uint // Copy the data to a packet buffer. buf = System::PacketBufferHandle::NewWithData(value, len); VerifyOrExit(!buf.IsNull(), err = CHIP_ERROR_NO_MEMORY); - NotifyBLENotificationReceived(buf, conId); + NotifyBLENotificationReceived(conId, buf); return; exit: if (err != CHIP_NO_ERROR) diff --git a/src/platform/Tizen/BLEManagerImpl.h b/src/platform/Tizen/BLEManagerImpl.h index ed30b92aa958b7..5dfee7fba75c83 100644 --- a/src/platform/Tizen/BLEManagerImpl.h +++ b/src/platform/Tizen/BLEManagerImpl.h @@ -196,13 +196,13 @@ class BLEManagerImpl final : public BLEManager, bool IsDeviceChipPeripheral(BLE_CONNECTION_OBJECT conId); // ==== BLE Adv & GATT Server. - void NotifyBLEPeripheralGATTServerRegisterComplete(bool aIsSuccess, void * apAppstate); - void NotifyBLEPeripheralAdvConfiguredComplete(bool aIsSuccess, void * apAppstate); - void NotifyBLEPeripheralAdvStartComplete(bool aIsSuccess, void * apAppstate); - void NotifyBLEPeripheralAdvStopComplete(bool aIsSuccess, void * apAppstate); - void NotifyBLESubscribed(bool indicationsEnabled, BLE_CONNECTION_OBJECT conId); + void NotifyBLEPeripheralGATTServerRegisterComplete(CHIP_ERROR error); + void NotifyBLEPeripheralAdvConfiguredComplete(CHIP_ERROR error); + void NotifyBLEPeripheralAdvStartComplete(CHIP_ERROR error); + void NotifyBLEPeripheralAdvStopComplete(CHIP_ERROR error); + void NotifyBLESubscribed(BLE_CONNECTION_OBJECT conId, bool indicationsEnabled); void NotifyBLEIndicationConfirmation(BLE_CONNECTION_OBJECT conId); - void NotifyBLEWriteReceived(System::PacketBufferHandle & buf, BLE_CONNECTION_OBJECT conId); + void NotifyBLEWriteReceived(BLE_CONNECTION_OBJECT conId, System::PacketBufferHandle & buf); static void HandleAdvertisingTimeout(chip::System::Layer *, void * appState); AdvertisingIntervals GetAdvertisingIntervals() const; @@ -214,7 +214,7 @@ class BLEManagerImpl final : public BLEManager, void NotifyHandleConnectFailed(CHIP_ERROR error); void NotifyHandleWriteComplete(BLE_CONNECTION_OBJECT conId); void NotifySubscribeOpComplete(BLE_CONNECTION_OBJECT conId, bool isSubscribed); - void NotifyBLENotificationReceived(System::PacketBufferHandle & buf, BLE_CONNECTION_OBJECT conId); + void NotifyBLENotificationReceived(BLE_CONNECTION_OBJECT conId, System::PacketBufferHandle & buf); CHIP_ERROR RegisterGATTServer(); CHIP_ERROR StartBLEAdvertising(); diff --git a/src/platform/Tizen/CHIPDevicePlatformEvent.h b/src/platform/Tizen/CHIPDevicePlatformEvent.h index 2145b18b448c8f..ce606fd7f576fd 100644 --- a/src/platform/Tizen/CHIPDevicePlatformEvent.h +++ b/src/platform/Tizen/CHIPDevicePlatformEvent.h @@ -23,6 +23,7 @@ #pragma once +#include #include #include @@ -67,23 +68,19 @@ struct ChipDevicePlatformEvent { struct { - bool mIsSuccess; - void * mpAppstate; + CHIP_ERROR mError; } BLEPeripheralGATTServerRegisterComplete; struct { - bool mIsSuccess; - void * mpAppstate; + CHIP_ERROR mError; } BLEPeripheralAdvConfiguredComplete; struct { - bool mIsSuccess; - void * mpAppstate; + CHIP_ERROR mError; } BLEPeripheralAdvStartComplete; struct { - bool mIsSuccess; - void * mpAppstate; + CHIP_ERROR mError; } BLEPeripheralAdvStopComplete; struct {