From c9b5cb777c653dba31e25b7a2117578c49d28837 Mon Sep 17 00:00:00 2001 From: Kevin Schoedel Date: Wed, 8 Sep 2021 15:23:08 -0400 Subject: [PATCH 1/5] Make platform PlatformManager::PostEvent() return status #### Problem `void PlatformManager::PostEvent()` can fail on some platforms, but does not report this to callers. In the #9543 case, an intermediate layer unconditionally returned `CHIP_NO_ERROR`, and `Inet` code assumed it could actually test whether `PostEvent()` succeeded. Fixes #9543 _PacketBuffer leak_ #### Change overview Made `PlatformManager::PostEvent()` return `CHIP_ERROR`. Marked it `[[nodiscard]]` to catch all uses, and made callers propagate or at least log any error. #### Testing CI. --- src/include/platform/PlatformManager.h | 17 ++++++++-- .../GenericConfigurationManagerImpl.cpp | 4 +-- .../GenericConnectivityManagerImpl_Thread.cpp | 6 +++- .../internal/GenericPlatformManagerImpl.cpp | 6 +++- .../GenericPlatformManagerImpl_FreeRTOS.cpp | 18 ++++++----- .../GenericPlatformManagerImpl_FreeRTOS.h | 2 +- .../GenericPlatformManagerImpl_POSIX.cpp | 3 +- .../GenericPlatformManagerImpl_POSIX.h | 2 +- .../GenericPlatformManagerImpl_Zephyr.cpp | 13 +++++--- .../GenericPlatformManagerImpl_Zephyr.h | 2 +- src/platform/Darwin/PlatformManagerImpl.cpp | 3 +- src/platform/Darwin/PlatformManagerImpl.h | 2 +- src/platform/DeviceControlServer.cpp | 8 +++-- src/platform/EFR32/BLEManagerImpl.cpp | 16 +++++----- .../ESP32/ConnectivityManagerImpl.cpp | 12 +++---- src/platform/ESP32/PlatformManagerImpl.cpp | 2 +- .../ESP32/bluedroid/BLEManagerImpl.cpp | 18 +++++------ src/platform/ESP32/nimble/BLEManagerImpl.cpp | 16 +++++----- src/platform/K32W/BLEManagerImpl.cpp | 19 ++++++------ src/platform/Linux/BLEManagerImpl.cpp | 28 ++++++++--------- .../Linux/ConnectivityManagerImpl.cpp | 2 +- src/platform/Linux/PlatformManagerImpl.cpp | 6 +++- src/platform/Linux/ThreadStackManagerImpl.cpp | 14 +++++++-- src/platform/LwIPEventSupport.cpp | 4 +-- ...nericThreadStackManagerImpl_OpenThread.cpp | 8 +++-- ...ThreadStackManagerImpl_OpenThread_LwIP.cpp | 6 +++- src/platform/P6/BLEManagerImpl.cpp | 31 ++++++++++++++----- src/platform/P6/ConnectivityManagerImpl.cpp | 6 ++-- src/platform/Zephyr/BLEManagerImpl.cpp | 18 +++++------ src/platform/cc13x2_26x2/BLEManagerImpl.cpp | 10 +++--- src/platform/fake/PlatformManagerImpl.h | 2 +- src/platform/mbed/BLEManagerImpl.cpp | 16 +++++----- src/platform/mbed/ConnectivityManagerImpl.cpp | 16 +++++----- src/platform/mbed/PlatformManagerImpl.cpp | 4 ++- src/platform/mbed/PlatformManagerImpl.h | 3 +- src/platform/qpg/BLEManagerImpl.cpp | 14 ++++----- 36 files changed, 215 insertions(+), 142 deletions(-) diff --git a/src/include/platform/PlatformManager.h b/src/include/platform/PlatformManager.h index cceeb432027a2d..ef0c69acd02f83 100644 --- a/src/include/platform/PlatformManager.h +++ b/src/include/platform/PlatformManager.h @@ -190,7 +190,8 @@ class PlatformManager * processing, the event might get dispatched (on the work item processing * thread) before PostEvent returns. */ - void PostEvent(const ChipDeviceEvent * event); + [[nodiscard]] CHIP_ERROR PostEvent(const ChipDeviceEvent * event); + CHIP_ERROR PostEventLoggingErrors(const ChipDeviceEvent * event); void DispatchEvent(const ChipDeviceEvent * event); CHIP_ERROR StartChipTimer(uint32_t durationMS); @@ -354,9 +355,19 @@ inline void PlatformManager::UnlockChipStack() static_cast(this)->_UnlockChipStack(); } -inline void PlatformManager::PostEvent(const ChipDeviceEvent * event) +inline CHIP_ERROR PlatformManager::PostEvent(const ChipDeviceEvent * event) { - static_cast(this)->_PostEvent(event); + return static_cast(this)->_PostEvent(event); +} + +inline CHIP_ERROR PlatformManager::PostEventLoggingErrors(const ChipDeviceEvent * event) +{ + CHIP_ERROR status = static_cast(this)->_PostEvent(event); + if (status != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to post event %d: %" CHIP_ERROR_FORMAT, static_cast(event->Type), status.Format()); + } + return status; } inline void PlatformManager::DispatchEvent(const ChipDeviceEvent * event) diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp index bac6cca73583ee..0c41154264a67a 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp @@ -794,7 +794,7 @@ CHIP_ERROR GenericConfigurationManagerImpl::_ClearServiceProvisioning ChipDeviceEvent event; event.Type = DeviceEventType::kAccountPairingChange; event.AccountPairingChange.IsPairedToAccount = false; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); } // If necessary, post an event alerting other subsystems to the change in @@ -805,7 +805,7 @@ CHIP_ERROR GenericConfigurationManagerImpl::_ClearServiceProvisioning event.Type = DeviceEventType::kServiceProvisioningChange; event.ServiceProvisioningChange.IsServiceProvisioned = false; event.ServiceProvisioningChange.ServiceConfigUpdated = false; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); } mFlags.Clear(Flags::kIsServiceProvisioned); diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp index 672f404637a10d..b02aed72f903a3 100644 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp +++ b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp @@ -109,7 +109,11 @@ void GenericConnectivityManagerImpl_Thread::UpdateServiceConnectivity event.ServiceConnectivityChange.ViaThread.Result = (haveServiceConnectivity) ? kConnectivity_Established : kConnectivity_Lost; event.ServiceConnectivityChange.Overall.Result = event.ServiceConnectivityChange.ViaThread.Result; - PlatformMgr().PostEvent(&event); + CHIP_ERROR status = PlatformMgr().PostEvent(&event); + if (status != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to post thread connectivity change: %" CHIP_ERROR_FORMAT, status.Format()); + } } } } diff --git a/src/include/platform/internal/GenericPlatformManagerImpl.cpp b/src/include/platform/internal/GenericPlatformManagerImpl.cpp index 0cdbb44e7ce4d8..0c58290dc5551e 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl.cpp +++ b/src/include/platform/internal/GenericPlatformManagerImpl.cpp @@ -201,7 +201,11 @@ void GenericPlatformManagerImpl::_ScheduleWork(AsyncWorkFunct workFun event.CallWorkFunct.WorkFunct = workFunct; event.CallWorkFunct.Arg = arg; - Impl()->PostEvent(&event); + CHIP_ERROR status = Impl()->PostEvent(&event); + if (status != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to schedule work: %" CHIP_ERROR_FORMAT, status.Format()); + } } template diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.cpp b/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.cpp index a83b6c34fef570..41d7cbcff00492 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.cpp +++ b/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.cpp @@ -98,15 +98,19 @@ void GenericPlatformManagerImpl_FreeRTOS::_UnlockChipStack(void) } template -void GenericPlatformManagerImpl_FreeRTOS::_PostEvent(const ChipDeviceEvent * event) +CHIP_ERROR GenericPlatformManagerImpl_FreeRTOS::_PostEvent(const ChipDeviceEvent * event) { - if (mChipEventQueue != NULL) + if (mChipEventQueue == NULL) { - if (!xQueueSend(mChipEventQueue, event, 1)) - { - ChipLogError(DeviceLayer, "Failed to post event to CHIP Platform event queue"); - } + return CHIP_ERROR_INTERNAL; + } + BaseType_t status = xQueueSend(mChipEventQueue, event, 1); + if (status != pdTRUE) + { + ChipLogError(DeviceLayer, "Failed to post event to CHIP Platform event queue"); + return CHIP_ERROR(chip::ChipError::Range::kOS, status); } + return CHIP_NO_ERROR; } template @@ -218,7 +222,7 @@ CHIP_ERROR GenericPlatformManagerImpl_FreeRTOS::_StartChipTimer(uint3 { ChipDeviceEvent event; event.Type = DeviceEventType::kNoOp; - Impl()->PostEvent(&event); + ReturnErrorOnFailure(Impl()->PostEvent(&event)); } return CHIP_NO_ERROR; diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.h b/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.h index 24c5a65a4d864c..8382a4cb757bfd 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.h +++ b/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.h @@ -68,7 +68,7 @@ class GenericPlatformManagerImpl_FreeRTOS : public GenericPlatformManagerImpl::_StartChipTimer(int64_t } template -void GenericPlatformManagerImpl_POSIX::_PostEvent(const ChipDeviceEvent * event) +CHIP_ERROR GenericPlatformManagerImpl_POSIX::_PostEvent(const ChipDeviceEvent * event) { mChipEventQueue.Push(*event); SystemLayer.Signal(); // Trigger wake select on CHIP thread + return CHIP_NO_ERROR; } template diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.h b/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.h index 2916cb0ca789a7..de0250e039673f 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.h +++ b/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.h @@ -89,7 +89,7 @@ class GenericPlatformManagerImpl_POSIX : public GenericPlatformManagerImpl template inherits. #include +#include #include #define DEFAULT_MIN_SLEEP_PERIOD (60 * 60 * 24 * 30) // Month [sec] @@ -100,15 +101,19 @@ CHIP_ERROR GenericPlatformManagerImpl_Zephyr::_Shutdown(void) } template -void GenericPlatformManagerImpl_Zephyr::_PostEvent(const ChipDeviceEvent * event) +CHIP_ERROR GenericPlatformManagerImpl_Zephyr::_PostEvent(const ChipDeviceEvent * event) { // For some reasons mentioned in https://github.com/zephyrproject-rtos/zephyr/issues/22301 // k_msgq_put takes `void*` instead of `const void*`. Nonetheless, it should be safe to // const_cast here and there are components in Zephyr itself which do the same. - if (k_msgq_put(&mChipEventQueue, const_cast(event), K_NO_WAIT) == 0) - SystemLayer.Signal(); // Trigger wake on CHIP thread - else + int status = k_msgq_put(&mChipEventQueue, const_cast(event), K_NO_WAIT); + if (status != 0) + { ChipLogError(DeviceLayer, "Failed to post event to CHIP Platform event queue"); + return System::MapErrorZephyr(status); + } + SystemLayer.Signal(); // Trigger wake on CHIP thread + return CHIP_NO_ERROR; } template diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h index 1ac68adae4955e..6c4a6a2eda1094 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h +++ b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h @@ -73,7 +73,7 @@ class GenericPlatformManagerImpl_Zephyr : public GenericPlatformManagerImpl::_Shutdown(); } -void PlatformManagerImpl::_PostEvent(const ChipDeviceEvent * event) +CHIP_ERROR PlatformManagerImpl::_PostEvent(const ChipDeviceEvent * event) { const ChipDeviceEvent eventCopy = *event; dispatch_async(mWorkQueue, ^{ Impl()->DispatchEvent(&eventCopy); }); + return CHIP_NO_ERROR; } } // namespace DeviceLayer diff --git a/src/platform/Darwin/PlatformManagerImpl.h b/src/platform/Darwin/PlatformManagerImpl.h index d0990b6e3e3179..1c58a1c0d54b56 100644 --- a/src/platform/Darwin/PlatformManagerImpl.h +++ b/src/platform/Darwin/PlatformManagerImpl.h @@ -65,7 +65,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener void _LockChipStack(){}; bool _TryLockChipStack() { return false; }; void _UnlockChipStack(){}; - void _PostEvent(const ChipDeviceEvent * event); + CHIP_ERROR _PostEvent(const ChipDeviceEvent * event); #if CHIP_STACK_LOCK_TRACKING_ENABLED bool _IsChipStackLockedByCurrentThread() const { return false; }; diff --git a/src/platform/DeviceControlServer.cpp b/src/platform/DeviceControlServer.cpp index 0f85b96819a412..ada14ffa84107c 100644 --- a/src/platform/DeviceControlServer.cpp +++ b/src/platform/DeviceControlServer.cpp @@ -46,7 +46,11 @@ void DeviceControlServer::CommissioningFailedTimerComplete() ChipDeviceEvent event; event.Type = DeviceEventType::kCommissioningComplete; event.CommissioningComplete.status = CHIP_ERROR_TIMEOUT; - PlatformMgr().PostEvent(&event); + CHIP_ERROR status = PlatformMgr().PostEvent(&event); + if (status != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to post commissioning complete: %" CHIP_ERROR_FORMAT, status.Format()); + } } CHIP_ERROR DeviceControlServer::ArmFailSafe(uint16_t expiryLengthSeconds) @@ -68,7 +72,7 @@ CHIP_ERROR DeviceControlServer::CommissioningComplete() ChipDeviceEvent event; event.Type = DeviceEventType::kCommissioningComplete; event.CommissioningComplete.status = CHIP_NO_ERROR; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); return CHIP_NO_ERROR; } diff --git a/src/platform/EFR32/BLEManagerImpl.cpp b/src/platform/EFR32/BLEManagerImpl.cpp index 0ed06b9e0448c5..d0625416223d68 100644 --- a/src/platform/EFR32/BLEManagerImpl.cpp +++ b/src/platform/EFR32/BLEManagerImpl.cpp @@ -423,7 +423,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) ChipLogProgress(DeviceLayer, "_OnPlatformEvent kCHIPoBLESubscribe"); HandleSubscribeReceived(event->CHIPoBLESubscribe.ConId, &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX); connEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEvent(&connEstEvent); + PlatformMgr().PostEventLoggingErrors(&connEstEvent); } break; @@ -523,7 +523,7 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU { event.Type = DeviceEventType::kCHIPoBLENotifyConfirm; event.CHIPoBLENotifyConfirm.ConId = conId; - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } exit: @@ -881,7 +881,7 @@ void BLEManagerImpl::HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt) ChipLogProgress(DeviceLayer, "BLE GATT connection closed (con %u, reason %u)", connHandle, conn_evt->reason); - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); // Arrange to re-enable connectable advertising in case it was disabled due to the // maximum connection limit being reached. @@ -931,7 +931,7 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(volatile sl_bt_msg_t * evt) { event.Type = DeviceEventType::kCHIPoBLESubscribe; event.CHIPoBLESubscribe.ConId = evt->data.evt_gatt_server_user_write_request.connection; - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } } } @@ -940,7 +940,7 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(volatile sl_bt_msg_t * evt) bleConnState->subscribed = 0; event.Type = DeviceEventType::kCHIPoBLEUnsubscribe; event.CHIPoBLESubscribe.ConId = evt->data.evt_gatt_server_user_write_request.connection; - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } exit: @@ -970,7 +970,7 @@ void BLEManagerImpl::HandleRXCharWrite(volatile sl_bt_msg_t * evt) event.Type = DeviceEventType::kCHIPoBLEWriteReceived; event.CHIPoBLEWriteReceived.ConId = evt->data.evt_gatt_server_user_write_request.connection; event.CHIPoBLEWriteReceived.Data = std::move(buf).UnsafeRelease(); - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } exit: @@ -996,7 +996,7 @@ void BLEManagerImpl::HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId) event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = conId; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } void BLEManagerImpl::HandleSoftTimerEvent(volatile sl_bt_msg_t * evt) @@ -1011,7 +1011,7 @@ void BLEManagerImpl::HandleSoftTimerEvent(volatile sl_bt_msg_t * evt) event.CHIPoBLEConnectionError.ConId = mIndConfId[evt->data.evt_system_soft_timer.handle]; sInstance.mIndConfId[evt->data.evt_system_soft_timer.handle] = kUnusedIndex; event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } } diff --git a/src/platform/ESP32/ConnectivityManagerImpl.cpp b/src/platform/ESP32/ConnectivityManagerImpl.cpp index 57b8b678a6a233..eac646bde716b6 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl.cpp @@ -667,7 +667,7 @@ void ConnectivityManagerImpl::OnStationConnected() ChipDeviceEvent event; event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Established; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); UpdateInternetConnectivityState(); } @@ -680,7 +680,7 @@ void ConnectivityManagerImpl::OnStationDisconnected() ChipDeviceEvent event; event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Lost; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); UpdateInternetConnectivityState(); } @@ -950,7 +950,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) event.InternetConnectivityChange.IPv4 = GetConnectivityChange(hadIPv4Conn, haveIPv4Conn); event.InternetConnectivityChange.IPv6 = GetConnectivityChange(hadIPv6Conn, haveIPv6Conn); addr.ToString(event.InternetConnectivityChange.address); - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); if (haveIPv4Conn != hadIPv4Conn) { @@ -981,7 +981,7 @@ void ConnectivityManagerImpl::OnStationIPv4AddressAvailable(const ip_event_got_i ChipDeviceEvent event; event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Assigned; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } void ConnectivityManagerImpl::OnStationIPv4AddressLost(void) @@ -995,7 +995,7 @@ void ConnectivityManagerImpl::OnStationIPv4AddressLost(void) ChipDeviceEvent event; event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Lost; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } void ConnectivityManagerImpl::OnIPv6AddressAvailable(const ip_event_got_ip6_t & got_ip) @@ -1014,7 +1014,7 @@ void ConnectivityManagerImpl::OnIPv6AddressAvailable(const ip_event_got_ip6_t & ChipDeviceEvent event; event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV6_Assigned; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } void ConnectivityManagerImpl::RefreshMessageLayer(void) {} diff --git a/src/platform/ESP32/PlatformManagerImpl.cpp b/src/platform/ESP32/PlatformManagerImpl.cpp index f6e7ef64bbf216..27bbe8bc579e48 100644 --- a/src/platform/ESP32/PlatformManagerImpl.cpp +++ b/src/platform/ESP32/PlatformManagerImpl.cpp @@ -192,7 +192,7 @@ void PlatformManagerImpl::HandleESPSystemEvent(void * arg, esp_event_base_t even } } - sInstance.PostEvent(&event); + sInstance.PostEventLoggingErrors(&event); } } // namespace DeviceLayer diff --git a/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp b/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp index 3d9718ef8487a4..c3266fa7a16259 100644 --- a/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp +++ b/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp @@ -280,7 +280,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) { ChipDeviceEvent connectionEvent; connectionEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEvent(&connectionEvent); + PlatformMgr().PostEventLoggingErrors(&connectionEvent); } break; @@ -1007,7 +1007,7 @@ void BLEManagerImpl::HandleRXCharWrite(esp_ble_gatts_cb_param_t * param) event.Type = DeviceEventType::kCHIPoBLEWriteReceived; event.CHIPoBLEWriteReceived.ConId = param->write.conn_id; event.CHIPoBLEWriteReceived.Data = std::move(buf).UnsafeRelease(); - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } exit: @@ -1099,7 +1099,7 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(esp_ble_gatts_cb_param_t * param) ChipDeviceEvent event; event.Type = (indicationsEnabled) ? DeviceEventType::kCHIPoBLESubscribe : DeviceEventType::kCHIPoBLEUnsubscribe; event.CHIPoBLESubscribe.ConId = param->write.conn_id; - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } ChipLogProgress(DeviceLayer, "CHIPoBLE %s received", indicationsEnabled ? "subscribe" : "unsubscribe"); @@ -1131,7 +1131,7 @@ void BLEManagerImpl::HandleTXCharConfirm(CHIPoBLEConState * conState, esp_ble_ga ChipDeviceEvent event; event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = param->conf.conn_id; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } else @@ -1140,7 +1140,7 @@ void BLEManagerImpl::HandleTXCharConfirm(CHIPoBLEConState * conState, esp_ble_ga event.Type = DeviceEventType::kCHIPoBLEConnectionError; event.CHIPoBLEConnectionError.ConId = param->disconnect.conn_id; event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } } @@ -1168,11 +1168,11 @@ void BLEManagerImpl::HandleDisconnect(esp_ble_gatts_cb_param_t * param) event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; break; } - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); ChipDeviceEvent disconnectEvent; disconnectEvent.Type = DeviceEventType::kCHIPoBLEConnectionClosed; - PlatformMgr().PostEvent(&disconnectEvent); + PlatformMgr().PostEventLoggingErrors(&disconnectEvent); // Force a refresh of the advertising state. mFlags.Set(Flags::kAdvertisingRefreshNeeded); @@ -1305,7 +1305,7 @@ void BLEManagerImpl::HandleGAPEvent(esp_gap_ble_cb_event_t event, esp_ble_gap_cb ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Started; - PlatformMgr().PostEvent(&advChange); + err = PlatformMgr().PostEvent(&advChange); } } @@ -1340,7 +1340,7 @@ void BLEManagerImpl::HandleGAPEvent(esp_gap_ble_cb_event_t event, esp_ble_gap_cb ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Stopped; - PlatformMgr().PostEvent(&advChange); + err = PlatformMgr().PostEvent(&advChange); } } diff --git a/src/platform/ESP32/nimble/BLEManagerImpl.cpp b/src/platform/ESP32/nimble/BLEManagerImpl.cpp index e19e0dad86a808..0bf5689c5c5006 100644 --- a/src/platform/ESP32/nimble/BLEManagerImpl.cpp +++ b/src/platform/ESP32/nimble/BLEManagerImpl.cpp @@ -277,7 +277,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) { ChipDeviceEvent connectionEvent; connectionEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEvent(&connectionEvent); + PlatformMgr().PostEventLoggingErrors(&connectionEvent); } break; @@ -531,7 +531,7 @@ void BLEManagerImpl::DriveBLEState(void) ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Started; - PlatformMgr().PostEvent(&advChange); + err = PlatformMgr().PostEvent(&advChange); } } } @@ -566,7 +566,7 @@ void BLEManagerImpl::DriveBLEState(void) ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Stopped; - PlatformMgr().PostEvent(&advChange); + err = PlatformMgr().PostEvent(&advChange); } } @@ -738,7 +738,7 @@ void BLEManagerImpl::HandleRXCharWrite(struct ble_gatt_char_context * param) event.Type = DeviceEventType::kCHIPoBLEWriteReceived; event.CHIPoBLEWriteReceived.ConId = param->conn_handle; event.CHIPoBLEWriteReceived.Data = std::move(buf).UnsafeRelease(); - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } exit: @@ -802,7 +802,7 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(struct ble_gap_event * gapEvent) event.Type = (indicationsEnabled || notificationsEnabled) ? DeviceEventType::kCHIPoBLESubscribe : DeviceEventType::kCHIPoBLEUnsubscribe; event.CHIPoBLESubscribe.ConId = gapEvent->subscribe.conn_handle; - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } ChipLogProgress(DeviceLayer, "CHIPoBLE %s received", @@ -830,7 +830,7 @@ CHIP_ERROR BLEManagerImpl::HandleTXComplete(struct ble_gap_event * gapEvent) ChipDeviceEvent event; event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = gapEvent->notify_tx.conn_handle; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); } else @@ -839,7 +839,7 @@ CHIP_ERROR BLEManagerImpl::HandleTXComplete(struct ble_gap_event * gapEvent) event.Type = DeviceEventType::kCHIPoBLEConnectionError; event.CHIPoBLEConnectionError.ConId = gapEvent->notify_tx.conn_handle; event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); } return CHIP_NO_ERROR; @@ -908,7 +908,7 @@ CHIP_ERROR BLEManagerImpl::HandleGAPDisconnect(struct ble_gap_event * gapEvent) ChipDeviceEvent disconnectEvent; disconnectEvent.Type = DeviceEventType::kCHIPoBLEConnectionClosed; - PlatformMgr().PostEvent(&disconnectEvent); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&disconnectEvent)); // Force a reconfiguration of advertising in case we switched to non-connectable mode when // the BLE connection was established. diff --git a/src/platform/K32W/BLEManagerImpl.cpp b/src/platform/K32W/BLEManagerImpl.cpp index d3ec43a8cbd9d7..b88cc305ed35e4 100644 --- a/src/platform/K32W/BLEManagerImpl.cpp +++ b/src/platform/K32W/BLEManagerImpl.cpp @@ -403,7 +403,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) HandleSubscribeReceived(event->CHIPoBLESubscribe.ConId, &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX); connEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEvent(&connEstEvent); + PlatformMgr().PostEventLoggingErrors(&connEstEvent); break; case DeviceEventType::kCHIPoBLEUnsubscribe: @@ -510,7 +510,7 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU { event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = conId; - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } if (err != CHIP_NO_ERROR) @@ -908,7 +908,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Started; - PlatformMgr().PostEvent(&advChange); + err = PlatformMgr().PostEvent(&advChange); } return err; @@ -917,6 +917,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) CHIP_ERROR BLEManagerImpl::StopAdvertising(void) { ble_err_t err; + CHIP_ERROR error = CHIP_NO_ERROR; if (mFlags.Has(Flags::kAdvertising)) { @@ -936,13 +937,13 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void) ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Stopped; - PlatformMgr().PostEvent(&advChange); + error = PlatformMgr().PostEvent(&advChange); } } } CancelBleAdvTimeoutTimer(); - return CHIP_NO_ERROR; + return error; } void BLEManagerImpl::DriveBLEState(void) @@ -1074,7 +1075,7 @@ void BLEManagerImpl::HandleConnectionCloseEvent(blekw_msg_t * msg) event.CHIPoBLEConnectionError.ConId = device_id_loc; event.CHIPoBLEConnectionError.Reason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); mFlags.Set(Flags::kRestartAdvertising); mFlags.Set(Flags::kFastAdvertisingEnabled); PlatformMgr().ScheduleWork(DriveBLEState, 0); @@ -1148,7 +1149,7 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(blekw_msg_t * msg) { event.Type = DeviceEventType::kCHIPoBLESubscribe; event.CHIPoBLESubscribe.ConId = att_wr_data->device_id; - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } } } @@ -1157,7 +1158,7 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(blekw_msg_t * msg) bleConnState->subscribed = 0; event.Type = DeviceEventType::kCHIPoBLEUnsubscribe; event.CHIPoBLESubscribe.ConId = att_wr_data->device_id; - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } exit: @@ -1195,7 +1196,7 @@ void BLEManagerImpl::HandleRXCharWrite(blekw_msg_t * msg) event.Type = DeviceEventType::kCHIPoBLEWriteReceived; event.CHIPoBLEWriteReceived.ConId = att_wr_data->device_id; event.CHIPoBLEWriteReceived.Data = std::move(buf).UnsafeRelease(); - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } exit: if (err != CHIP_NO_ERROR) diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index 04be62f725fadb..7c34b4eb4d205a 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -222,7 +222,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) { ChipDeviceEvent connectionEvent; connectionEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEvent(&connectionEvent); + PlatformMgr().PostEventLoggingErrors(&connectionEvent); } break; @@ -439,7 +439,7 @@ void BLEManagerImpl::HandleNewConnection(BLE_CONNECTION_OBJECT conId) ChipDeviceEvent event; event.Type = DeviceEventType::kPlatformLinuxBLECentralConnected; event.Platform.BLECentralConnected.mConnection = conId; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } } @@ -450,7 +450,7 @@ void BLEManagerImpl::HandleConnectFailed(CHIP_ERROR error) ChipDeviceEvent event; event.Type = DeviceEventType::kPlatformLinuxBLECentralConnectFailed; event.Platform.BLECentralConnectFailed.mError = error; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } } @@ -459,7 +459,7 @@ void BLEManagerImpl::HandleWriteComplete(BLE_CONNECTION_OBJECT conId) ChipDeviceEvent event; event.Type = DeviceEventType::kPlatformLinuxBLEWriteComplete; event.Platform.BLEWriteComplete.mConnection = conId; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } void BLEManagerImpl::HandleSubscribeOpComplete(BLE_CONNECTION_OBJECT conId, bool subscribed) @@ -468,7 +468,7 @@ void BLEManagerImpl::HandleSubscribeOpComplete(BLE_CONNECTION_OBJECT conId, bool event.Type = DeviceEventType::kPlatformLinuxBLESubscribeOpComplete; event.Platform.BLESubscribeOpComplete.mConnection = conId; event.Platform.BLESubscribeOpComplete.mIsSubscribed = subscribed; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } void BLEManagerImpl::HandleTXCharChanged(BLE_CONNECTION_OBJECT conId, const uint8_t * value, size_t len) @@ -484,7 +484,7 @@ void BLEManagerImpl::HandleTXCharChanged(BLE_CONNECTION_OBJECT conId, const uint event.Type = DeviceEventType::kPlatformLinuxBLEIndicationReceived; event.Platform.BLEIndicationReceived.mConnection = conId; event.Platform.BLEIndicationReceived.mData = std::move(buf).UnsafeRelease(); - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); exit: if (err != CHIP_NO_ERROR) @@ -507,7 +507,7 @@ void BLEManagerImpl::HandleRXCharWrite(BLE_CONNECTION_OBJECT conId, const uint8_ ChipLogProgress(Ble, "Write request received debug %p", conId); event.CHIPoBLEWriteReceived.ConId = conId; event.CHIPoBLEWriteReceived.Data = std::move(buf).UnsafeRelease(); - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } exit: @@ -527,7 +527,7 @@ void BLEManagerImpl::CHIPoBluez_ConnectionClosed(BLE_CONNECTION_OBJECT conId) event.Type = DeviceEventType::kCHIPoBLEConnectionError; event.CHIPoBLEConnectionError.ConId = conId; event.CHIPoBLEConnectionError.Reason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } } @@ -546,7 +546,7 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(BLE_CONNECTION_OBJECT conId) ChipDeviceEvent event; event.Type = connection->mIsNotify ? DeviceEventType::kCHIPoBLESubscribe : DeviceEventType::kCHIPoBLEUnsubscribe; event.CHIPoBLESubscribe.ConId = connection; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } ChipLogProgress(DeviceLayer, "CHIPoBLE %s received", connection->mIsNotify ? "subscribe" : "unsubscribe"); @@ -565,7 +565,7 @@ void BLEManagerImpl::HandleTXComplete(BLE_CONNECTION_OBJECT conId) ChipDeviceEvent event; event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = conId; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } void BLEManagerImpl::DriveBLEState() @@ -745,7 +745,7 @@ void BLEManagerImpl::NotifyBLEPeripheralRegisterAppComplete(bool aIsSuccess, voi event.Type = DeviceEventType::kPlatformLinuxBLEPeripheralRegisterAppComplete; event.Platform.BLEPeripheralRegisterAppComplete.mIsSuccess = aIsSuccess; event.Platform.BLEPeripheralRegisterAppComplete.mpAppstate = apAppstate; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } void BLEManagerImpl::NotifyBLEPeripheralAdvConfiguredComplete(bool aIsSuccess, void * apAppstate) @@ -754,7 +754,7 @@ void BLEManagerImpl::NotifyBLEPeripheralAdvConfiguredComplete(bool aIsSuccess, v event.Type = DeviceEventType::kPlatformLinuxBLEPeripheralAdvConfiguredComplete; event.Platform.BLEPeripheralAdvConfiguredComplete.mIsSuccess = aIsSuccess; event.Platform.BLEPeripheralAdvConfiguredComplete.mpAppstate = apAppstate; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } void BLEManagerImpl::NotifyBLEPeripheralAdvStartComplete(bool aIsSuccess, void * apAppstate) @@ -763,7 +763,7 @@ void BLEManagerImpl::NotifyBLEPeripheralAdvStartComplete(bool aIsSuccess, void * event.Type = DeviceEventType::kPlatformLinuxBLEPeripheralAdvStartComplete; event.Platform.BLEPeripheralAdvStartComplete.mIsSuccess = aIsSuccess; event.Platform.BLEPeripheralAdvStartComplete.mpAppstate = apAppstate; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } void BLEManagerImpl::NotifyBLEPeripheralAdvStopComplete(bool aIsSuccess, void * apAppstate) @@ -772,7 +772,7 @@ void BLEManagerImpl::NotifyBLEPeripheralAdvStopComplete(bool aIsSuccess, void * event.Type = DeviceEventType::kPlatformLinuxBLEPeripheralAdvStopComplete; event.Platform.BLEPeripheralAdvStopComplete.mIsSuccess = aIsSuccess; event.Platform.BLEPeripheralAdvStopComplete.mpAppstate = apAppstate; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } void BLEManagerImpl::OnDeviceScanned(BluezDevice1 * device, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index 5f2159b19212c4..d7a97ca05f619f 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -941,7 +941,7 @@ CHIP_ERROR ConnectivityManagerImpl::ProvisionWiFiNetwork(const char * ssid, cons ChipLogDetail(DeviceLayer, "Got IP address on interface: %s IP: %s", ifName, event.InternetConnectivityChange.address); - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); } } } diff --git a/src/platform/Linux/PlatformManagerImpl.cpp b/src/platform/Linux/PlatformManagerImpl.cpp index 4604f34d1f3821..015221b74cc6de 100644 --- a/src/platform/Linux/PlatformManagerImpl.cpp +++ b/src/platform/Linux/PlatformManagerImpl.cpp @@ -107,7 +107,11 @@ void PlatformManagerImpl::WiFIIPChangeListener() ChipLogDetail(DeviceLayer, "Got IP address on interface: %s IP: %s", name, event.InternetConnectivityChange.address); - PlatformMgr().PostEvent(&event); + CHIP_ERROR status = PlatformMgr().PostEvent(&event); + if (status != CHIP_NO_ERROR) + { + ChipLogDetail(DeviceLayer, "Failed to report IP address: %" CHIP_ERROR_FORMAT, status.Format()); + } } routeInfo = RTA_NEXT(routeInfo, rtl); } diff --git a/src/platform/Linux/ThreadStackManagerImpl.cpp b/src/platform/Linux/ThreadStackManagerImpl.cpp index bbc3ca55d62bd2..856f6106c7d677 100644 --- a/src/platform/Linux/ThreadStackManagerImpl.cpp +++ b/src/platform/Linux/ThreadStackManagerImpl.cpp @@ -107,13 +107,21 @@ void ThreadStackManagerImpl::ThreadDevcieRoleChangedHandler(const gchar * role) event.Type = DeviceEventType::kThreadConnectivityChange; event.ThreadConnectivityChange.Result = attached ? ConnectivityChange::kConnectivity_Established : ConnectivityChange::kConnectivity_Lost; - PlatformMgr().PostEvent(&event); + CHIP_ERROR status = PlatformMgr().PostEvent(&event); + if (status != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to post thread connectivity change: %" CHIP_ERROR_FORMAT, status.Format()); + } } mAttached = attached; event.Type = DeviceEventType::kThreadStateChange; event.ThreadStateChange.RoleChanged = true; - PlatformMgr().PostEvent(&event); + CHIP_ERROR status = PlatformMgr().PostEvent(&event); + if (status != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to post thread state change: %" CHIP_ERROR_FORMAT, status.Format()); + } } void ThreadStackManagerImpl::_ProcessThreadActivity() {} @@ -212,7 +220,7 @@ CHIP_ERROR ThreadStackManagerImpl::_SetThreadProvision(ByteSpan netInfo) ChipDeviceEvent event; event.Type = DeviceEventType::kServiceProvisioningChange; event.ServiceProvisioningChange.IsServiceProvisioned = true; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); return CHIP_NO_ERROR; } diff --git a/src/platform/LwIPEventSupport.cpp b/src/platform/LwIPEventSupport.cpp index 9f92385092e484..f51a02b6689d7b 100644 --- a/src/platform/LwIPEventSupport.cpp +++ b/src/platform/LwIPEventSupport.cpp @@ -43,9 +43,7 @@ CHIP_ERROR PlatformEventing::PostEvent(System::Layer & aLayer, System::Object & event.ChipSystemLayerEvent.Target = &aTarget; event.ChipSystemLayerEvent.Argument = aArgument; - PlatformMgr().PostEvent(&event); - - return CHIP_NO_ERROR; + return PlatformMgr().PostEvent(&event); } CHIP_ERROR PlatformEventing::DispatchEvents(System::Layer & aLayer) diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp index 140df4b25ef605..b0633449b55c03 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp @@ -89,7 +89,11 @@ void GenericThreadStackManagerImpl_OpenThread::OnOpenThreadStateChang event.ThreadStateChange.ChildNodesChanged = (flags & (OT_CHANGED_THREAD_CHILD_ADDED | OT_CHANGED_THREAD_CHILD_REMOVED)) != 0; event.ThreadStateChange.OpenThread.Flags = flags; - PlatformMgr().PostEvent(&event); + CHIP_ERROR status = PlatformMgr().PostEvent(&event); + if (status != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to post Thread state change: %" CHIP_ERROR_FORMAT, status.Format()); + } } template @@ -245,7 +249,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_SetThreadProvis ChipDeviceEvent event; event.Type = DeviceEventType::kServiceProvisioningChange; event.ServiceProvisioningChange.IsServiceProvisioned = true; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); return MapOpenThreadError(otErr); } diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp index d73665f0a6f057..63e760a05e5677 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp @@ -153,7 +153,11 @@ void GenericThreadStackManagerImpl_OpenThread_LwIP::UpdateThreadInter event.Clear(); event.Type = DeviceEventType::kThreadConnectivityChange; event.ThreadConnectivityChange.Result = (isInterfaceUp) ? kConnectivity_Established : kConnectivity_Lost; - PlatformMgr().PostEvent(&event); + CHIP_ERROR status = PlatformMgr().PostEvent(&event); + if (status != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to post Thread connectivity change: %" CHIP_ERROR_FORMAT, status.Format()); + } } // Presume the interface addresses are also changing. diff --git a/src/platform/P6/BLEManagerImpl.cpp b/src/platform/P6/BLEManagerImpl.cpp index ec058c51541cb8..c49e340d2e45bd 100644 --- a/src/platform/P6/BLEManagerImpl.cpp +++ b/src/platform/P6/BLEManagerImpl.cpp @@ -80,7 +80,10 @@ wiced_result_t BLEManagerImpl::BLEManagerCallback(wiced_bt_management_evt_t even ChipDeviceEvent bleEvent; bleEvent.Type = DeviceEventType::kP6BLEEnabledEvt; - PlatformMgr().PostEvent(&bleEvent); + if (PlatformMgr().PostEvent(&bleEvent) != CHIP_NO_ERROR) + { + return WICED_BT_ERROR; + } } break; } @@ -238,7 +241,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) { ChipDeviceEvent _event; _event.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEvent(&_event); + PlatformMgr().PostEventLoggingErrors(&_event); } break; @@ -428,7 +431,7 @@ void BLEManagerImpl::DriveBLEState(void) ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Started; - PlatformMgr().PostEvent(&advChange); + err = PlatformMgr().PostEvent(&advChange); } } } @@ -553,13 +556,18 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceWrite(uint16_t conn_id, event.Type = DeviceEventType::kCHIPoBLEWriteReceived; event.CHIPoBLEWriteReceived.ConId = conn_id; event.CHIPoBLEWriteReceived.Data = buf; - PlatformMgr().PostEvent(&event); + CHIP_ERROR status = PlatformMgr().PostEventLoggingErrors(&event); + if (status != CHIP_NO_ERROR) + { + result = WICED_BT_GATT_INTERNAL_ERROR; + } buf = NULL; } } else { ChipLogError(DeviceLayer, "BLEManagerImpl: Out of buffers during CHIPoBLE RX"); + result = WICED_BT_GATT_NO_RESOURCES; } } else @@ -584,7 +592,10 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceWrite(uint16_t conn_id, event.Type = (app_chip_service_char_tx_client_char_config[0] != 0) ? DeviceEventType::kCHIPoBLESubscribe : DeviceEventType::kCHIPoBLEUnsubscribe; event.CHIPoBLESubscribe.ConId = conn_id; - PlatformMgr().PostEvent(&event); + if (PlatformMgr().PostEvent(&event) != CHIP_NO_ERROR) + { + return WICED_BT_GATT_INTERNAL_ERROR; + } } ChipLogProgress(DeviceLayer, "CHIPoBLE %s received", @@ -617,7 +628,10 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceIndCfm(uint16_t conn_id, ChipDeviceEvent event; event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = conn_id; - PlatformMgr().PostEvent(&event); + if (PlatformMgr().PostEvent(&event) != CHIP_NO_ERROR) + { + return WICED_BT_GATT_INTERNAL_ERROR; + } } return WICED_BT_GATT_SUCCESS; } @@ -691,7 +705,10 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattConnectEvent(wiced_bt_gatt_conn ChipLogProgress(DeviceLayer, "BLE GATT connection closed (con %u, reason %u)", p_conn_status->conn_id, p_conn_status->reason); - PlatformMgr().PostEvent(&event); + if (PlatformMgr().PostEvent(&event) != CHIP_NO_ERROR) + { + return WICED_BT_GATT_INTERNAL_ERROR; + } // Arrange to re-enable connectable advertising in case it was disabled due to the // maximum connection limit being reached. diff --git a/src/platform/P6/ConnectivityManagerImpl.cpp b/src/platform/P6/ConnectivityManagerImpl.cpp index 58037edca9db8e..b2e9d6c7e5b7d4 100644 --- a/src/platform/P6/ConnectivityManagerImpl.cpp +++ b/src/platform/P6/ConnectivityManagerImpl.cpp @@ -611,7 +611,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) ChipDeviceEvent event; event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Assigned; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } // Search among the IPv6 addresses assigned to the interface for a Global Unicast // address (2000::/3) that is in the valid state. If such an address is found... @@ -624,7 +624,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) ChipDeviceEvent event; event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV6_Assigned; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } } } @@ -642,7 +642,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) event.InternetConnectivityChange.IPv4 = GetConnectivityChange(hadIPv4Conn, haveIPv4Conn); event.InternetConnectivityChange.IPv6 = GetConnectivityChange(hadIPv6Conn, haveIPv6Conn); addr.ToString(event.InternetConnectivityChange.address); - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); if (haveIPv4Conn != hadIPv4Conn) { diff --git a/src/platform/Zephyr/BLEManagerImpl.cpp b/src/platform/Zephyr/BLEManagerImpl.cpp index baacd6dae64727..a66b5d3f15e21a 100644 --- a/src/platform/Zephyr/BLEManagerImpl.cpp +++ b/src/platform/Zephyr/BLEManagerImpl.cpp @@ -285,7 +285,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Started; - PlatformMgr().PostEvent(&advChange); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&advChange)); } if (mFlags.Has(Flags::kFastAdvertisingEnabled)) @@ -324,7 +324,7 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void) ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Stopped; - PlatformMgr().PostEvent(&advChange); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&advChange)); } // Cancel timer event disabling CHIPoBLE advertisement after timeout expiration @@ -469,7 +469,7 @@ CHIP_ERROR BLEManagerImpl::HandleGAPDisconnect(const ChipDeviceEvent * event) ChipDeviceEvent disconnectEvent; disconnectEvent.Type = DeviceEventType::kCHIPoBLEConnectionClosed; - PlatformMgr().PostEvent(&disconnectEvent); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&disconnectEvent)); // Force a reconfiguration of advertising in case we switched to non-connectable mode when // the BLE connection was established. @@ -499,7 +499,7 @@ CHIP_ERROR BLEManagerImpl::HandleTXCharCCCDWrite(const ChipDeviceEvent * event) { ChipDeviceEvent conEstEvent; conEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEvent(&conEstEvent); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&conEstEvent)); } } else @@ -764,7 +764,7 @@ ssize_t BLEManagerImpl::HandleRXWrite(struct bt_conn * conId, const struct bt_ga event.Type = DeviceEventType::kPlatformZephyrBleOutOfBuffersEvent; } - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); return len; } @@ -782,7 +782,7 @@ ssize_t BLEManagerImpl::HandleTXCCCWrite(struct bt_conn * conId, const struct bt event.Platform.BleCCCWriteEvent.BtConn = bt_conn_ref(conId); event.Platform.BleCCCWriteEvent.Value = value; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); return sizeof(value); } @@ -794,7 +794,7 @@ void BLEManagerImpl::HandleTXCompleted(struct bt_conn * conId, void * /* param * event.Type = DeviceEventType::kPlatformZephyrBleTXComplete; event.Platform.BleTXCompleteEvent.BtConn = bt_conn_ref(conId); - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } void BLEManagerImpl::HandleConnect(struct bt_conn * conId, uint8_t err) @@ -810,7 +810,7 @@ void BLEManagerImpl::HandleConnect(struct bt_conn * conId, uint8_t err) event.Platform.BleConnEvent.BtConn = bt_conn_ref(conId); event.Platform.BleConnEvent.HciResult = err; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); exit: PlatformMgr().UnlockChipStack(); @@ -829,7 +829,7 @@ void BLEManagerImpl::HandleDisconnect(struct bt_conn * conId, uint8_t reason) event.Platform.BleConnEvent.BtConn = bt_conn_ref(conId); event.Platform.BleConnEvent.HciResult = reason; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); exit: PlatformMgr().UnlockChipStack(); diff --git a/src/platform/cc13x2_26x2/BLEManagerImpl.cpp b/src/platform/cc13x2_26x2/BLEManagerImpl.cpp index 1b64bcbf107f83..4992041d4657d7 100644 --- a/src/platform/cc13x2_26x2/BLEManagerImpl.cpp +++ b/src/platform/cc13x2_26x2/BLEManagerImpl.cpp @@ -241,7 +241,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) connEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEvent(&connEstEvent); + PlatformMgr().PostEventLoggingErrors(&connEstEvent); } break; @@ -900,7 +900,7 @@ void BLEManagerImpl::ProcessEvtHdrMsg(QueuedEvt_t * pMsg) event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = connHandle; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); dealloc = TRUE; } @@ -984,7 +984,7 @@ void BLEManagerImpl::ProcessEvtHdrMsg(QueuedEvt_t * pMsg) // Post event to CHIP event.CHIPoBLESubscribe.ConId = (void *) connHandle; } - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } break; @@ -1144,7 +1144,7 @@ void BLEManagerImpl::ProcessGapMessage(gapEventHdr_t * pMsg) event.Type = DeviceEventType::kCHIPoBLEConnectionError; event.CHIPoBLEConnectionError.ConId = (void *) &pPkt->connectionHandle; event.CHIPoBLEConnectionError.Reason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); DriveBLEState(); @@ -1248,7 +1248,7 @@ uint8_t BLEManagerImpl::ProcessGATTMsg(gattMsgEvent_t * pMsg) event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = connHandle; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); BLEMGR_LOG("BLEMGR: ProcessGATTMsg, ATT_HANDLE_VALUE_CFM:"); } diff --git a/src/platform/fake/PlatformManagerImpl.h b/src/platform/fake/PlatformManagerImpl.h index 7e726374e909cd..0483a4c88d0893 100644 --- a/src/platform/fake/PlatformManagerImpl.h +++ b/src/platform/fake/PlatformManagerImpl.h @@ -50,7 +50,7 @@ class PlatformManagerImpl final : public PlatformManager void _RunEventLoop() {} CHIP_ERROR _StartEventLoopTask() { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR _StopEventLoopTask() { return CHIP_ERROR_NOT_IMPLEMENTED; } - void _PostEvent(const ChipDeviceEvent * event) {} + CHIP_ERROR _PostEvent(const ChipDeviceEvent * event) { return CHIP_NO_ERROR; } void _DispatchEvent(const ChipDeviceEvent * event) {} CHIP_ERROR _StartChipTimer(int64_t durationMS) { return CHIP_ERROR_NOT_IMPLEMENTED; } diff --git a/src/platform/mbed/BLEManagerImpl.cpp b/src/platform/mbed/BLEManagerImpl.cpp index 8a55d8e822c151..15fd7bbdeedf7b 100644 --- a/src/platform/mbed/BLEManagerImpl.cpp +++ b/src/platform/mbed/BLEManagerImpl.cpp @@ -184,7 +184,7 @@ class GapEventHandler : private mbed::NonCopyable, public ble:: ChipDeviceEvent chip_event; chip_event.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; chip_event.CHIPoBLEAdvertisingChange.Result = kActivity_Started; - PlatformMgrImpl().PostEvent(&chip_event); + PlatformMgrImpl().PostEventLoggingErrors(&chip_event); PlatformMgr().ScheduleWork(ble_manager.DriveBLEState, 0); } @@ -208,7 +208,7 @@ class GapEventHandler : private mbed::NonCopyable, public ble:: ChipDeviceEvent chip_event; chip_event.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; chip_event.CHIPoBLEAdvertisingChange.Result = kActivity_Stopped; - PlatformMgrImpl().PostEvent(&chip_event); + PlatformMgrImpl().PostEventLoggingErrors(&chip_event); if (event.isConnected()) { @@ -305,7 +305,7 @@ class GapEventHandler : private mbed::NonCopyable, public ble:: chip_event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; break; } - PlatformMgrImpl().PostEvent(&chip_event); + PlatformMgrImpl().PostEventLoggingErrors(&chip_event); ChipLogProgress(DeviceLayer, "BLE connection terminated, mbed-os reason: %d", reason.value()); ChipLogProgress(DeviceLayer, "Current number of connections: %" PRIu16 "/%d", ble_manager.NumConnections(), @@ -397,7 +397,7 @@ struct CHIPService : public ble::GattServer::EventHandler chip_event.Type = DeviceEventType::kCHIPoBLEWriteReceived; chip_event.CHIPoBLEWriteReceived.ConId = params->connHandle; chip_event.CHIPoBLEWriteReceived.Data = std::move(buf).UnsafeRelease(); - PlatformMgrImpl().PostEvent(&chip_event); + PlatformMgrImpl().PostEventLoggingErrors(&chip_event); } else { @@ -447,7 +447,7 @@ struct CHIPService : public ble::GattServer::EventHandler ChipDeviceEvent chip_event; chip_event.Type = DeviceEventType::kCHIPoBLESubscribe; chip_event.CHIPoBLESubscribe.ConId = params.connHandle; - PlatformMgrImpl().PostEvent(&chip_event); + PlatformMgrImpl().PostEventLoggingErrors(&chip_event); } } @@ -460,7 +460,7 @@ struct CHIPService : public ble::GattServer::EventHandler ChipDeviceEvent chip_event; chip_event.Type = DeviceEventType::kCHIPoBLEUnsubscribe; chip_event.CHIPoBLEUnsubscribe.ConId = params.connHandle; - PlatformMgrImpl().PostEvent(&chip_event); + PlatformMgrImpl().PostEventLoggingErrors(&chip_event); } } @@ -473,7 +473,7 @@ struct CHIPService : public ble::GattServer::EventHandler ChipDeviceEvent chip_event; chip_event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; chip_event.CHIPoBLEIndicateConfirm.ConId = params.connHandle; - PlatformMgrImpl().PostEvent(&chip_event); + PlatformMgrImpl().PostEventLoggingErrors(&chip_event); } } @@ -926,7 +926,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) ChipLogDetail(DeviceLayer, "_OnPlatformEvent kCHIPoBLESubscribe"); HandleSubscribeReceived(event->CHIPoBLESubscribe.ConId, &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX); connEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgrImpl().PostEvent(&connEstEvent); + PlatformMgrImpl().PostEventLoggingErrors(&connEstEvent); } break; diff --git a/src/platform/mbed/ConnectivityManagerImpl.cpp b/src/platform/mbed/ConnectivityManagerImpl.cpp index c2a24562f1b949..81edfdaddf7c24 100644 --- a/src/platform/mbed/ConnectivityManagerImpl.cpp +++ b/src/platform/mbed/ConnectivityManagerImpl.cpp @@ -246,7 +246,7 @@ CHIP_ERROR ConnectivityManagerImpl::OnStationConnected() ChipDeviceEvent event; event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Established; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); ChipLogProgress(DeviceLayer, "Event - StationConnected"); } @@ -263,7 +263,7 @@ CHIP_ERROR ConnectivityManagerImpl::OnStationConnected() event.Type = DeviceEventType::kInternetConnectivityChange; event.InternetConnectivityChange.IPv4 = kConnectivity_Lost; event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); ChipLogError(DeviceLayer, "Unnexpected loss of Ip4 address"); } } @@ -277,7 +277,7 @@ CHIP_ERROR ConnectivityManagerImpl::OnStationConnected() event.Type = DeviceEventType::kInternetConnectivityChange; event.InternetConnectivityChange.IPv4 = kConnectivity_Established; event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); ChipLogProgress(DeviceLayer, "New Ip4 address set: %s", address.get_ip_address()); } } @@ -294,7 +294,7 @@ CHIP_ERROR ConnectivityManagerImpl::OnStationConnected() event.Type = DeviceEventType::kInternetConnectivityChange; event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange; event.InternetConnectivityChange.IPv6 = kConnectivity_Lost; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); ChipLogError(DeviceLayer, "Unnexpected loss of Ip6 address"); } } @@ -308,7 +308,7 @@ CHIP_ERROR ConnectivityManagerImpl::OnStationConnected() event.Type = DeviceEventType::kInternetConnectivityChange; event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange; event.InternetConnectivityChange.IPv6 = kConnectivity_Established; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); ChipLogProgress(DeviceLayer, "New Ip6 address set %s", address.get_ip_address()); } } @@ -326,7 +326,7 @@ CHIP_ERROR ConnectivityManagerImpl::OnStationDisconnected() ChipDeviceEvent event; event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Lost; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); ChipLogProgress(DeviceLayer, "Event - StationDisconnected"); } @@ -339,7 +339,7 @@ CHIP_ERROR ConnectivityManagerImpl::OnStationDisconnected() event.Type = DeviceEventType::kInternetConnectivityChange; event.InternetConnectivityChange.IPv4 = kConnectivity_Lost; event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); ChipLogError(DeviceLayer, "Loss of Ip4 address"); } @@ -351,7 +351,7 @@ CHIP_ERROR ConnectivityManagerImpl::OnStationDisconnected() event.Type = DeviceEventType::kInternetConnectivityChange; event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange; event.InternetConnectivityChange.IPv6 = kConnectivity_Lost; - PlatformMgr().PostEvent(&event); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); ChipLogError(DeviceLayer, "Loss of Ip6 address"); } diff --git a/src/platform/mbed/PlatformManagerImpl.cpp b/src/platform/mbed/PlatformManagerImpl.cpp index 205839424bdd08..fd4359d7d92d72 100644 --- a/src/platform/mbed/PlatformManagerImpl.cpp +++ b/src/platform/mbed/PlatformManagerImpl.cpp @@ -98,7 +98,7 @@ void PlatformManagerImpl::_UnlockChipStack() mChipStackMutex.unlock(); } -void PlatformManagerImpl::_PostEvent(const ChipDeviceEvent * eventPtr) +CHIP_ERROR PlatformManagerImpl::_PostEvent(const ChipDeviceEvent * eventPtr) { auto handle = mQueue.call([event = *eventPtr, this] { LockChipStack(); @@ -109,7 +109,9 @@ void PlatformManagerImpl::_PostEvent(const ChipDeviceEvent * eventPtr) if (!handle) { ChipLogError(DeviceLayer, "Error posting event: Not enough memory"); + return CHIP_ERROR_NO_MEMORY; } + return CHIP_NO_ERROR; } void PlatformManagerImpl::ProcessDeviceEvents() diff --git a/src/platform/mbed/PlatformManagerImpl.h b/src/platform/mbed/PlatformManagerImpl.h index ad9cff5c552d3e..f8b021557a936e 100644 --- a/src/platform/mbed/PlatformManagerImpl.h +++ b/src/platform/mbed/PlatformManagerImpl.h @@ -77,7 +77,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener void _LockChipStack(); bool _TryLockChipStack(); void _UnlockChipStack(); - void _PostEvent(const ChipDeviceEvent * event); + CHIP_ERROR _PostEvent(const ChipDeviceEvent * event); void _RunEventLoop(); CHIP_ERROR _StartEventLoopTask(); CHIP_ERROR _StopEventLoopTask(); @@ -96,6 +96,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener friend class Internal::CHIPService; using PlatformManager::PostEvent; + using PlatformManager::PostEventLoggingErrors; static PlatformManagerImpl sInstance; // ===== Members for internal use. diff --git a/src/platform/qpg/BLEManagerImpl.cpp b/src/platform/qpg/BLEManagerImpl.cpp index 475fcbbd398b95..6e22d29a5deedc 100644 --- a/src/platform/qpg/BLEManagerImpl.cpp +++ b/src/platform/qpg/BLEManagerImpl.cpp @@ -199,7 +199,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) ChipLogProgress(DeviceLayer, "_OnPlatformEvent kCHIPoBLESubscribe"); HandleSubscribeReceived(event->CHIPoBLESubscribe.ConId, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_TX); connEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEvent(&connEstEvent); + PlatformMgr().PostEventLoggingErrors(&connEstEvent); } break; @@ -559,7 +559,7 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void) ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Stopped; - PlatformMgr().PostEvent(&advChange); + err = PlatformMgr().PostEvent(&advChange); } } @@ -612,7 +612,7 @@ void BLEManagerImpl::HandleRXCharWrite(uint16_t connId, uint16_t handle, uint8_t event.Type = DeviceEventType::kCHIPoBLEWriteReceived; event.CHIPoBLEWriteReceived.ConId = connId; event.CHIPoBLEWriteReceived.Data = std::move(buf).UnsafeRelease(); - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } exit: @@ -658,7 +658,7 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(qvCHIP_Ble_AttsCccEvt_t * pEvt) ChipDeviceEvent event; event.Type = (notificationsEnabled) ? DeviceEventType::kCHIPoBLESubscribe : DeviceEventType::kCHIPoBLEUnsubscribe; event.CHIPoBLESubscribe.ConId = pEvt->hdr.param; - PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } ChipLogProgress(DeviceLayer, "CHIPoBLE %s received", notificationsEnabled ? "subscribe" : "unsubscribe"); @@ -706,7 +706,7 @@ void BLEManagerImpl::HandleDmMsg(qvCHIP_Ble_DmEvt_t * pDmEvt) ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Started; - PlatformMgr().PostEvent(&advChange); + PlatformMgr().PostEventLoggingErrors(&advChange); } } break; @@ -764,7 +764,7 @@ void BLEManagerImpl::HandleDmMsg(qvCHIP_Ble_DmEvt_t * pDmEvt) event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; break; } - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); } mFlags.Set(Flags::kAdvertisingRefreshNeeded); @@ -793,7 +793,7 @@ void BLEManagerImpl::HandleAttMsg(qvCHIP_Ble_AttEvt_t * pAttEvt) event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = pAttEvt->hdr.param; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventLoggingErrors(&event); break; } case QVCHIP_ATTC_FIND_BY_TYPE_VALUE_RSP: From 2a278224ee79d4a8eee1ea3e56ecfcf92d2e1f01 Mon Sep 17 00:00:00 2001 From: Kevin Schoedel Date: Thu, 9 Sep 2021 18:09:08 -0400 Subject: [PATCH 2/5] address review comments --- .../internal/GenericConfigurationManagerImpl.cpp | 13 ++++++++++--- src/platform/DeviceControlServer.cpp | 3 +-- src/platform/Linux/ConnectivityManagerImpl.cpp | 2 +- src/platform/Linux/ThreadStackManagerImpl.cpp | 4 +--- .../GenericThreadStackManagerImpl_OpenThread.cpp | 8 +++++--- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp index 0c41154264a67a..6e24aedd9e533f 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp @@ -781,11 +781,14 @@ CHIP_ERROR GenericConfigurationManagerImpl::_StoreServiceProvisioning template CHIP_ERROR GenericConfigurationManagerImpl::_ClearServiceProvisioningData() { + CHIP_ERROR err = CHIP_NO_ERROR; + Impl()->ClearConfigValue(ImplClass::kConfigKey_ServiceId); Impl()->ClearConfigValue(ImplClass::kConfigKey_ServiceConfig); Impl()->ClearConfigValue(ImplClass::kConfigKey_PairedAccountId); // TODO: Move these behaviors out of configuration manager. + // Also, should the flags be cleared even if the corresponding notification fails to post? // If necessary, post an event alerting other subsystems to the change in // the account pairing state. @@ -794,7 +797,7 @@ CHIP_ERROR GenericConfigurationManagerImpl::_ClearServiceProvisioning ChipDeviceEvent event; event.Type = DeviceEventType::kAccountPairingChange; event.AccountPairingChange.IsPairedToAccount = false; - ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); + err = PlatformMgr().PostEvent(&event); } // If necessary, post an event alerting other subsystems to the change in @@ -805,13 +808,17 @@ CHIP_ERROR GenericConfigurationManagerImpl::_ClearServiceProvisioning event.Type = DeviceEventType::kServiceProvisioningChange; event.ServiceProvisioningChange.IsServiceProvisioned = false; event.ServiceProvisioningChange.ServiceConfigUpdated = false; - ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); + CHIP_ERROR postError = PlatformMgr().PostEvent(&event); + if (err == CHIP_NO_ERROR) + { + err = postError; + } } mFlags.Clear(Flags::kIsServiceProvisioned); mFlags.Clear(Flags::kIsPairedToAccount); - return CHIP_NO_ERROR; + return err; } template diff --git a/src/platform/DeviceControlServer.cpp b/src/platform/DeviceControlServer.cpp index ada14ffa84107c..21ade7a698ff2a 100644 --- a/src/platform/DeviceControlServer.cpp +++ b/src/platform/DeviceControlServer.cpp @@ -72,8 +72,7 @@ CHIP_ERROR DeviceControlServer::CommissioningComplete() ChipDeviceEvent event; event.Type = DeviceEventType::kCommissioningComplete; event.CommissioningComplete.status = CHIP_NO_ERROR; - ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); - return CHIP_NO_ERROR; + return PlatformMgr().PostEvent(&event); } CHIP_ERROR DeviceControlServer::SetRegulatoryConfig(uint8_t location, const char * countryCode, uint64_t breadcrumb) diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index d7a97ca05f619f..775323e544fa21 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -941,7 +941,7 @@ CHIP_ERROR ConnectivityManagerImpl::ProvisionWiFiNetwork(const char * ssid, cons ChipLogDetail(DeviceLayer, "Got IP address on interface: %s IP: %s", ifName, event.InternetConnectivityChange.address); - ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); + PlatformMgr().PostEventLoggingErrors(&event); } } } diff --git a/src/platform/Linux/ThreadStackManagerImpl.cpp b/src/platform/Linux/ThreadStackManagerImpl.cpp index 856f6106c7d677..8e8509ae47870b 100644 --- a/src/platform/Linux/ThreadStackManagerImpl.cpp +++ b/src/platform/Linux/ThreadStackManagerImpl.cpp @@ -220,9 +220,7 @@ CHIP_ERROR ThreadStackManagerImpl::_SetThreadProvision(ByteSpan netInfo) ChipDeviceEvent event; event.Type = DeviceEventType::kServiceProvisioningChange; event.ServiceProvisioningChange.IsServiceProvisioned = true; - ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); - - return CHIP_NO_ERROR; + return PlatformMgr().PostEvent(&event); } CHIP_ERROR ThreadStackManagerImpl::_GetThreadProvision(ByteSpan & netInfo) diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp index b0633449b55c03..b2d504477011a5 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp @@ -244,14 +244,16 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_SetThreadProvis Impl()->LockThreadStack(); otErr = otDatasetSetActiveTlvs(mOTInst, &tlvs); Impl()->UnlockThreadStack(); + if (otErr != OT_ERROR_NONE) + { + return MapOpenThreadError(otErr); + } // post an event alerting other subsystems about change in provisioning state ChipDeviceEvent event; event.Type = DeviceEventType::kServiceProvisioningChange; event.ServiceProvisioningChange.IsServiceProvisioned = true; - ReturnErrorOnFailure(PlatformMgr().PostEvent(&event)); - - return MapOpenThreadError(otErr); + return PlatformMgr().PostEvent(&event); } template From aaa4cf82382324d1509d81c1224bbeb6cf89b01c Mon Sep 17 00:00:00 2001 From: Kevin Schoedel Date: Thu, 9 Sep 2021 19:23:08 -0400 Subject: [PATCH 3/5] restyle --- .../platform/internal/GenericConfigurationManagerImpl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp index 6e24aedd9e533f..383946f9bf58c2 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp @@ -797,7 +797,7 @@ CHIP_ERROR GenericConfigurationManagerImpl::_ClearServiceProvisioning ChipDeviceEvent event; event.Type = DeviceEventType::kAccountPairingChange; event.AccountPairingChange.IsPairedToAccount = false; - err = PlatformMgr().PostEvent(&event); + err = PlatformMgr().PostEvent(&event); } // If necessary, post an event alerting other subsystems to the change in @@ -808,7 +808,7 @@ CHIP_ERROR GenericConfigurationManagerImpl::_ClearServiceProvisioning event.Type = DeviceEventType::kServiceProvisioningChange; event.ServiceProvisioningChange.IsServiceProvisioned = false; event.ServiceProvisioningChange.ServiceConfigUpdated = false; - CHIP_ERROR postError = PlatformMgr().PostEvent(&event); + CHIP_ERROR postError = PlatformMgr().PostEvent(&event); if (err == CHIP_NO_ERROR) { err = postError; From 247ef483355cc1790052142db5bb6da5e5c38c28 Mon Sep 17 00:00:00 2001 From: Kevin Schoedel Date: Fri, 10 Sep 2021 14:29:21 -0400 Subject: [PATCH 4/5] replace PostEventLoggingErrors with PostEventOrDie --- src/include/platform/PlatformManager.h | 11 +++----- src/platform/EFR32/BLEManagerImpl.cpp | 8 +++--- .../ESP32/ConnectivityManagerImpl.cpp | 12 ++++---- src/platform/ESP32/PlatformManagerImpl.cpp | 2 +- .../ESP32/bluedroid/BLEManagerImpl.cpp | 10 +++---- src/platform/ESP32/nimble/BLEManagerImpl.cpp | 2 +- src/platform/K32W/BLEManagerImpl.cpp | 4 +-- src/platform/Linux/BLEManagerImpl.cpp | 28 +++++++++---------- .../Linux/ConnectivityManagerImpl.cpp | 2 +- src/platform/P6/BLEManagerImpl.cpp | 4 +-- src/platform/P6/ConnectivityManagerImpl.cpp | 6 ++-- src/platform/Zephyr/BLEManagerImpl.cpp | 10 +++---- src/platform/cc13x2_26x2/BLEManagerImpl.cpp | 10 +++---- src/platform/mbed/BLEManagerImpl.cpp | 16 +++++------ src/platform/mbed/PlatformManagerImpl.h | 2 +- src/platform/qpg/BLEManagerImpl.cpp | 8 +++--- 16 files changed, 66 insertions(+), 69 deletions(-) diff --git a/src/include/platform/PlatformManager.h b/src/include/platform/PlatformManager.h index ef0c69acd02f83..7f902b6a9c8829 100644 --- a/src/include/platform/PlatformManager.h +++ b/src/include/platform/PlatformManager.h @@ -191,7 +191,7 @@ class PlatformManager * thread) before PostEvent returns. */ [[nodiscard]] CHIP_ERROR PostEvent(const ChipDeviceEvent * event); - CHIP_ERROR PostEventLoggingErrors(const ChipDeviceEvent * event); + void PostEventOrDie(const ChipDeviceEvent * event); void DispatchEvent(const ChipDeviceEvent * event); CHIP_ERROR StartChipTimer(uint32_t durationMS); @@ -360,14 +360,11 @@ inline CHIP_ERROR PlatformManager::PostEvent(const ChipDeviceEvent * event) return static_cast(this)->_PostEvent(event); } -inline CHIP_ERROR PlatformManager::PostEventLoggingErrors(const ChipDeviceEvent * event) +inline void PlatformManager::PostEventOrDie(const ChipDeviceEvent * event) { CHIP_ERROR status = static_cast(this)->_PostEvent(event); - if (status != CHIP_NO_ERROR) - { - ChipLogError(DeviceLayer, "Failed to post event %d: %" CHIP_ERROR_FORMAT, static_cast(event->Type), status.Format()); - } - return status; + VerifyOrDieWithMsg(status == CHIP_NO_ERROR, DeviceLayer, "Failed to post event %d: %" CHIP_ERROR_FORMAT, + static_cast(event->Type), status.Format()); } inline void PlatformManager::DispatchEvent(const ChipDeviceEvent * event) diff --git a/src/platform/EFR32/BLEManagerImpl.cpp b/src/platform/EFR32/BLEManagerImpl.cpp index fb2fb6926f68b6..bbbf59105bdba5 100644 --- a/src/platform/EFR32/BLEManagerImpl.cpp +++ b/src/platform/EFR32/BLEManagerImpl.cpp @@ -423,7 +423,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) ChipLogProgress(DeviceLayer, "_OnPlatformEvent kCHIPoBLESubscribe"); HandleSubscribeReceived(event->CHIPoBLESubscribe.ConId, &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX); connEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEventLoggingErrors(&connEstEvent); + PlatformMgr().PostEventOrDie(&connEstEvent); } break; @@ -881,7 +881,7 @@ void BLEManagerImpl::HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt) ChipLogProgress(DeviceLayer, "BLE GATT connection closed (con %u, reason %u)", connHandle, conn_evt->reason); - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); // Arrange to re-enable connectable advertising in case it was disabled due to the // maximum connection limit being reached. @@ -996,7 +996,7 @@ void BLEManagerImpl::HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId) event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = conId; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::HandleSoftTimerEvent(volatile sl_bt_msg_t * evt) @@ -1011,7 +1011,7 @@ void BLEManagerImpl::HandleSoftTimerEvent(volatile sl_bt_msg_t * evt) event.CHIPoBLEConnectionError.ConId = mIndConfId[evt->data.evt_system_soft_timer.handle]; sInstance.mIndConfId[evt->data.evt_system_soft_timer.handle] = kUnusedIndex; event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } } diff --git a/src/platform/ESP32/ConnectivityManagerImpl.cpp b/src/platform/ESP32/ConnectivityManagerImpl.cpp index 511ede1ecfb2c2..7790c45fac90b8 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl.cpp @@ -667,7 +667,7 @@ void ConnectivityManagerImpl::OnStationConnected() ChipDeviceEvent event; event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Established; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); UpdateInternetConnectivityState(); } @@ -680,7 +680,7 @@ void ConnectivityManagerImpl::OnStationDisconnected() ChipDeviceEvent event; event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Lost; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); UpdateInternetConnectivityState(); } @@ -950,7 +950,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) event.InternetConnectivityChange.IPv4 = GetConnectivityChange(hadIPv4Conn, haveIPv4Conn); event.InternetConnectivityChange.IPv6 = GetConnectivityChange(hadIPv6Conn, haveIPv6Conn); addr.ToString(event.InternetConnectivityChange.address); - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); if (haveIPv4Conn != hadIPv4Conn) { @@ -981,7 +981,7 @@ void ConnectivityManagerImpl::OnStationIPv4AddressAvailable(const ip_event_got_i ChipDeviceEvent event; event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Assigned; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } void ConnectivityManagerImpl::OnStationIPv4AddressLost(void) @@ -995,7 +995,7 @@ void ConnectivityManagerImpl::OnStationIPv4AddressLost(void) ChipDeviceEvent event; event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Lost; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } void ConnectivityManagerImpl::OnIPv6AddressAvailable(const ip_event_got_ip6_t & got_ip) @@ -1014,7 +1014,7 @@ void ConnectivityManagerImpl::OnIPv6AddressAvailable(const ip_event_got_ip6_t & ChipDeviceEvent event; event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV6_Assigned; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } void ConnectivityManagerImpl::RefreshMessageLayer(void) {} diff --git a/src/platform/ESP32/PlatformManagerImpl.cpp b/src/platform/ESP32/PlatformManagerImpl.cpp index 27bbe8bc579e48..48ecb5e6ab81dc 100644 --- a/src/platform/ESP32/PlatformManagerImpl.cpp +++ b/src/platform/ESP32/PlatformManagerImpl.cpp @@ -192,7 +192,7 @@ void PlatformManagerImpl::HandleESPSystemEvent(void * arg, esp_event_base_t even } } - sInstance.PostEventLoggingErrors(&event); + sInstance.PostEventOrDie(&event); } } // namespace DeviceLayer diff --git a/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp b/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp index 4d531edc88bee9..694fae36fc6288 100644 --- a/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp +++ b/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp @@ -280,7 +280,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) { ChipDeviceEvent connectionEvent; connectionEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEventLoggingErrors(&connectionEvent); + PlatformMgr().PostEventOrDie(&connectionEvent); } break; @@ -1131,7 +1131,7 @@ void BLEManagerImpl::HandleTXCharConfirm(CHIPoBLEConState * conState, esp_ble_ga ChipDeviceEvent event; event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = param->conf.conn_id; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } else @@ -1140,7 +1140,7 @@ void BLEManagerImpl::HandleTXCharConfirm(CHIPoBLEConState * conState, esp_ble_ga event.Type = DeviceEventType::kCHIPoBLEConnectionError; event.CHIPoBLEConnectionError.ConId = param->disconnect.conn_id; event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } } @@ -1168,11 +1168,11 @@ void BLEManagerImpl::HandleDisconnect(esp_ble_gatts_cb_param_t * param) event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; break; } - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); ChipDeviceEvent disconnectEvent; disconnectEvent.Type = DeviceEventType::kCHIPoBLEConnectionClosed; - PlatformMgr().PostEventLoggingErrors(&disconnectEvent); + PlatformMgr().PostEventOrDie(&disconnectEvent); // Force a refresh of the advertising state. mFlags.Set(Flags::kAdvertisingRefreshNeeded); diff --git a/src/platform/ESP32/nimble/BLEManagerImpl.cpp b/src/platform/ESP32/nimble/BLEManagerImpl.cpp index e0fd2492e2172d..f60869fb91e2a3 100644 --- a/src/platform/ESP32/nimble/BLEManagerImpl.cpp +++ b/src/platform/ESP32/nimble/BLEManagerImpl.cpp @@ -277,7 +277,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) { ChipDeviceEvent connectionEvent; connectionEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEventLoggingErrors(&connectionEvent); + PlatformMgr().PostEventOrDie(&connectionEvent); } break; diff --git a/src/platform/K32W/BLEManagerImpl.cpp b/src/platform/K32W/BLEManagerImpl.cpp index 962e1801f3acd7..69cbda3df32a56 100644 --- a/src/platform/K32W/BLEManagerImpl.cpp +++ b/src/platform/K32W/BLEManagerImpl.cpp @@ -403,7 +403,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) HandleSubscribeReceived(event->CHIPoBLESubscribe.ConId, &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX); connEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEventLoggingErrors(&connEstEvent); + PlatformMgr().PostEventOrDie(&connEstEvent); break; case DeviceEventType::kCHIPoBLEUnsubscribe: @@ -1075,7 +1075,7 @@ void BLEManagerImpl::HandleConnectionCloseEvent(blekw_msg_t * msg) event.CHIPoBLEConnectionError.ConId = device_id_loc; event.CHIPoBLEConnectionError.Reason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); mFlags.Set(Flags::kRestartAdvertising); mFlags.Set(Flags::kFastAdvertisingEnabled); PlatformMgr().ScheduleWork(DriveBLEState, 0); diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index 4c7e7335c9ce88..9a6ea424e02934 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -222,7 +222,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) { ChipDeviceEvent connectionEvent; connectionEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEventLoggingErrors(&connectionEvent); + PlatformMgr().PostEventOrDie(&connectionEvent); } break; @@ -439,7 +439,7 @@ void BLEManagerImpl::HandleNewConnection(BLE_CONNECTION_OBJECT conId) ChipDeviceEvent event; event.Type = DeviceEventType::kPlatformLinuxBLECentralConnected; event.Platform.BLECentralConnected.mConnection = conId; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } } @@ -450,7 +450,7 @@ void BLEManagerImpl::HandleConnectFailed(CHIP_ERROR error) ChipDeviceEvent event; event.Type = DeviceEventType::kPlatformLinuxBLECentralConnectFailed; event.Platform.BLECentralConnectFailed.mError = error; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } } @@ -459,7 +459,7 @@ void BLEManagerImpl::HandleWriteComplete(BLE_CONNECTION_OBJECT conId) ChipDeviceEvent event; event.Type = DeviceEventType::kPlatformLinuxBLEWriteComplete; event.Platform.BLEWriteComplete.mConnection = conId; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::HandleSubscribeOpComplete(BLE_CONNECTION_OBJECT conId, bool subscribed) @@ -468,7 +468,7 @@ void BLEManagerImpl::HandleSubscribeOpComplete(BLE_CONNECTION_OBJECT conId, bool event.Type = DeviceEventType::kPlatformLinuxBLESubscribeOpComplete; event.Platform.BLESubscribeOpComplete.mConnection = conId; event.Platform.BLESubscribeOpComplete.mIsSubscribed = subscribed; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::HandleTXCharChanged(BLE_CONNECTION_OBJECT conId, const uint8_t * value, size_t len) @@ -484,7 +484,7 @@ void BLEManagerImpl::HandleTXCharChanged(BLE_CONNECTION_OBJECT conId, const uint event.Type = DeviceEventType::kPlatformLinuxBLEIndicationReceived; event.Platform.BLEIndicationReceived.mConnection = conId; event.Platform.BLEIndicationReceived.mData = std::move(buf).UnsafeRelease(); - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); exit: if (err != CHIP_NO_ERROR) @@ -507,7 +507,7 @@ void BLEManagerImpl::HandleRXCharWrite(BLE_CONNECTION_OBJECT conId, const uint8_ ChipLogProgress(Ble, "Write request received debug %p", conId); event.CHIPoBLEWriteReceived.ConId = conId; event.CHIPoBLEWriteReceived.Data = std::move(buf).UnsafeRelease(); - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } exit: @@ -527,7 +527,7 @@ void BLEManagerImpl::CHIPoBluez_ConnectionClosed(BLE_CONNECTION_OBJECT conId) event.Type = DeviceEventType::kCHIPoBLEConnectionError; event.CHIPoBLEConnectionError.ConId = conId; event.CHIPoBLEConnectionError.Reason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } } @@ -546,7 +546,7 @@ void BLEManagerImpl::HandleTXCharCCCDWrite(BLE_CONNECTION_OBJECT conId) ChipDeviceEvent event; event.Type = connection->mIsNotify ? DeviceEventType::kCHIPoBLESubscribe : DeviceEventType::kCHIPoBLEUnsubscribe; event.CHIPoBLESubscribe.ConId = connection; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } ChipLogProgress(DeviceLayer, "CHIPoBLE %s received", connection->mIsNotify ? "subscribe" : "unsubscribe"); @@ -565,7 +565,7 @@ void BLEManagerImpl::HandleTXComplete(BLE_CONNECTION_OBJECT conId) ChipDeviceEvent event; event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = conId; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::DriveBLEState() @@ -745,7 +745,7 @@ void BLEManagerImpl::NotifyBLEPeripheralRegisterAppComplete(bool aIsSuccess, voi event.Type = DeviceEventType::kPlatformLinuxBLEPeripheralRegisterAppComplete; event.Platform.BLEPeripheralRegisterAppComplete.mIsSuccess = aIsSuccess; event.Platform.BLEPeripheralRegisterAppComplete.mpAppstate = apAppstate; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::NotifyBLEPeripheralAdvConfiguredComplete(bool aIsSuccess, void * apAppstate) @@ -754,7 +754,7 @@ void BLEManagerImpl::NotifyBLEPeripheralAdvConfiguredComplete(bool aIsSuccess, v event.Type = DeviceEventType::kPlatformLinuxBLEPeripheralAdvConfiguredComplete; event.Platform.BLEPeripheralAdvConfiguredComplete.mIsSuccess = aIsSuccess; event.Platform.BLEPeripheralAdvConfiguredComplete.mpAppstate = apAppstate; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::NotifyBLEPeripheralAdvStartComplete(bool aIsSuccess, void * apAppstate) @@ -763,7 +763,7 @@ void BLEManagerImpl::NotifyBLEPeripheralAdvStartComplete(bool aIsSuccess, void * event.Type = DeviceEventType::kPlatformLinuxBLEPeripheralAdvStartComplete; event.Platform.BLEPeripheralAdvStartComplete.mIsSuccess = aIsSuccess; event.Platform.BLEPeripheralAdvStartComplete.mpAppstate = apAppstate; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::NotifyBLEPeripheralAdvStopComplete(bool aIsSuccess, void * apAppstate) @@ -772,7 +772,7 @@ void BLEManagerImpl::NotifyBLEPeripheralAdvStopComplete(bool aIsSuccess, void * event.Type = DeviceEventType::kPlatformLinuxBLEPeripheralAdvStopComplete; event.Platform.BLEPeripheralAdvStopComplete.mIsSuccess = aIsSuccess; event.Platform.BLEPeripheralAdvStopComplete.mpAppstate = apAppstate; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::OnDeviceScanned(BluezDevice1 * device, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index 419a7c74f19e05..17d862dda19ea1 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -941,7 +941,7 @@ CHIP_ERROR ConnectivityManagerImpl::ProvisionWiFiNetwork(const char * ssid, cons ChipLogDetail(DeviceLayer, "Got IP address on interface: %s IP: %s", ifName, event.InternetConnectivityChange.address); - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } } } diff --git a/src/platform/P6/BLEManagerImpl.cpp b/src/platform/P6/BLEManagerImpl.cpp index f3e86c9ab454d7..0ae901198ce453 100644 --- a/src/platform/P6/BLEManagerImpl.cpp +++ b/src/platform/P6/BLEManagerImpl.cpp @@ -241,7 +241,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) { ChipDeviceEvent _event; _event.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEventLoggingErrors(&_event); + PlatformMgr().PostEventOrDie(&_event); } break; @@ -556,7 +556,7 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceWrite(uint16_t conn_id, event.Type = DeviceEventType::kCHIPoBLEWriteReceived; event.CHIPoBLEWriteReceived.ConId = conn_id; event.CHIPoBLEWriteReceived.Data = buf; - CHIP_ERROR status = PlatformMgr().PostEventLoggingErrors(&event); + CHIP_ERROR status = PlatformMgr().PostEventOrDie(&event); if (status != CHIP_NO_ERROR) { result = WICED_BT_GATT_INTERNAL_ERROR; diff --git a/src/platform/P6/ConnectivityManagerImpl.cpp b/src/platform/P6/ConnectivityManagerImpl.cpp index f0d34e7f6429b7..1dd9d940d4f04e 100644 --- a/src/platform/P6/ConnectivityManagerImpl.cpp +++ b/src/platform/P6/ConnectivityManagerImpl.cpp @@ -611,7 +611,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) ChipDeviceEvent event; event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Assigned; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } // Search among the IPv6 addresses assigned to the interface for a Global Unicast // address (2000::/3) that is in the valid state. If such an address is found... @@ -624,7 +624,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) ChipDeviceEvent event; event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV6_Assigned; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } } } @@ -642,7 +642,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) event.InternetConnectivityChange.IPv4 = GetConnectivityChange(hadIPv4Conn, haveIPv4Conn); event.InternetConnectivityChange.IPv6 = GetConnectivityChange(hadIPv6Conn, haveIPv6Conn); addr.ToString(event.InternetConnectivityChange.address); - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); if (haveIPv4Conn != hadIPv4Conn) { diff --git a/src/platform/Zephyr/BLEManagerImpl.cpp b/src/platform/Zephyr/BLEManagerImpl.cpp index a3a8b5f4749fee..0ad70bdc7cc349 100644 --- a/src/platform/Zephyr/BLEManagerImpl.cpp +++ b/src/platform/Zephyr/BLEManagerImpl.cpp @@ -764,7 +764,7 @@ ssize_t BLEManagerImpl::HandleRXWrite(struct bt_conn * conId, const struct bt_ga event.Type = DeviceEventType::kPlatformZephyrBleOutOfBuffersEvent; } - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); return len; } @@ -782,7 +782,7 @@ ssize_t BLEManagerImpl::HandleTXCCCWrite(struct bt_conn * conId, const struct bt event.Platform.BleCCCWriteEvent.BtConn = bt_conn_ref(conId); event.Platform.BleCCCWriteEvent.Value = value; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); return sizeof(value); } @@ -794,7 +794,7 @@ void BLEManagerImpl::HandleTXCompleted(struct bt_conn * conId, void * /* param * event.Type = DeviceEventType::kPlatformZephyrBleTXComplete; event.Platform.BleTXCompleteEvent.BtConn = bt_conn_ref(conId); - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::HandleConnect(struct bt_conn * conId, uint8_t err) @@ -810,7 +810,7 @@ void BLEManagerImpl::HandleConnect(struct bt_conn * conId, uint8_t err) event.Platform.BleConnEvent.BtConn = bt_conn_ref(conId); event.Platform.BleConnEvent.HciResult = err; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); exit: PlatformMgr().UnlockChipStack(); @@ -829,7 +829,7 @@ void BLEManagerImpl::HandleDisconnect(struct bt_conn * conId, uint8_t reason) event.Platform.BleConnEvent.BtConn = bt_conn_ref(conId); event.Platform.BleConnEvent.HciResult = reason; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); exit: PlatformMgr().UnlockChipStack(); diff --git a/src/platform/cc13x2_26x2/BLEManagerImpl.cpp b/src/platform/cc13x2_26x2/BLEManagerImpl.cpp index 181dc1bbfe18fe..8f8905c96c5254 100644 --- a/src/platform/cc13x2_26x2/BLEManagerImpl.cpp +++ b/src/platform/cc13x2_26x2/BLEManagerImpl.cpp @@ -241,7 +241,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) connEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEventLoggingErrors(&connEstEvent); + PlatformMgr().PostEventOrDie(&connEstEvent); } break; @@ -900,7 +900,7 @@ void BLEManagerImpl::ProcessEvtHdrMsg(QueuedEvt_t * pMsg) event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = connHandle; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); dealloc = TRUE; } @@ -984,7 +984,7 @@ void BLEManagerImpl::ProcessEvtHdrMsg(QueuedEvt_t * pMsg) // Post event to CHIP event.CHIPoBLESubscribe.ConId = (void *) connHandle; } - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } break; @@ -1144,7 +1144,7 @@ void BLEManagerImpl::ProcessGapMessage(gapEventHdr_t * pMsg) event.Type = DeviceEventType::kCHIPoBLEConnectionError; event.CHIPoBLEConnectionError.ConId = (void *) &pPkt->connectionHandle; event.CHIPoBLEConnectionError.Reason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); DriveBLEState(); @@ -1248,7 +1248,7 @@ uint8_t BLEManagerImpl::ProcessGATTMsg(gattMsgEvent_t * pMsg) event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = connHandle; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); BLEMGR_LOG("BLEMGR: ProcessGATTMsg, ATT_HANDLE_VALUE_CFM:"); } diff --git a/src/platform/mbed/BLEManagerImpl.cpp b/src/platform/mbed/BLEManagerImpl.cpp index 4a186dd8194cfa..e297d26331cb96 100644 --- a/src/platform/mbed/BLEManagerImpl.cpp +++ b/src/platform/mbed/BLEManagerImpl.cpp @@ -184,7 +184,7 @@ class GapEventHandler : private mbed::NonCopyable, public ble:: ChipDeviceEvent chip_event; chip_event.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; chip_event.CHIPoBLEAdvertisingChange.Result = kActivity_Started; - PlatformMgrImpl().PostEventLoggingErrors(&chip_event); + PlatformMgrImpl().PostEventOrDie(&chip_event); PlatformMgr().ScheduleWork(ble_manager.DriveBLEState, 0); } @@ -208,7 +208,7 @@ class GapEventHandler : private mbed::NonCopyable, public ble:: ChipDeviceEvent chip_event; chip_event.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; chip_event.CHIPoBLEAdvertisingChange.Result = kActivity_Stopped; - PlatformMgrImpl().PostEventLoggingErrors(&chip_event); + PlatformMgrImpl().PostEventOrDie(&chip_event); if (event.isConnected()) { @@ -305,7 +305,7 @@ class GapEventHandler : private mbed::NonCopyable, public ble:: chip_event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; break; } - PlatformMgrImpl().PostEventLoggingErrors(&chip_event); + PlatformMgrImpl().PostEventOrDie(&chip_event); ChipLogProgress(DeviceLayer, "BLE connection terminated, mbed-os reason: %d", reason.value()); ChipLogProgress(DeviceLayer, "Current number of connections: %" PRIu16 "/%d", ble_manager.NumConnections(), @@ -397,7 +397,7 @@ struct CHIPService : public ble::GattServer::EventHandler chip_event.Type = DeviceEventType::kCHIPoBLEWriteReceived; chip_event.CHIPoBLEWriteReceived.ConId = params->connHandle; chip_event.CHIPoBLEWriteReceived.Data = std::move(buf).UnsafeRelease(); - PlatformMgrImpl().PostEventLoggingErrors(&chip_event); + PlatformMgrImpl().PostEventOrDie(&chip_event); } else { @@ -447,7 +447,7 @@ struct CHIPService : public ble::GattServer::EventHandler ChipDeviceEvent chip_event; chip_event.Type = DeviceEventType::kCHIPoBLESubscribe; chip_event.CHIPoBLESubscribe.ConId = params.connHandle; - PlatformMgrImpl().PostEventLoggingErrors(&chip_event); + PlatformMgrImpl().PostEventOrDie(&chip_event); } } @@ -460,7 +460,7 @@ struct CHIPService : public ble::GattServer::EventHandler ChipDeviceEvent chip_event; chip_event.Type = DeviceEventType::kCHIPoBLEUnsubscribe; chip_event.CHIPoBLEUnsubscribe.ConId = params.connHandle; - PlatformMgrImpl().PostEventLoggingErrors(&chip_event); + PlatformMgrImpl().PostEventOrDie(&chip_event); } } @@ -473,7 +473,7 @@ struct CHIPService : public ble::GattServer::EventHandler ChipDeviceEvent chip_event; chip_event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; chip_event.CHIPoBLEIndicateConfirm.ConId = params.connHandle; - PlatformMgrImpl().PostEventLoggingErrors(&chip_event); + PlatformMgrImpl().PostEventOrDie(&chip_event); } } @@ -926,7 +926,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) ChipLogDetail(DeviceLayer, "_OnPlatformEvent kCHIPoBLESubscribe"); HandleSubscribeReceived(event->CHIPoBLESubscribe.ConId, &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX); connEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgrImpl().PostEventLoggingErrors(&connEstEvent); + PlatformMgrImpl().PostEventOrDie(&connEstEvent); } break; diff --git a/src/platform/mbed/PlatformManagerImpl.h b/src/platform/mbed/PlatformManagerImpl.h index f8b021557a936e..ff5c04e558e5e9 100644 --- a/src/platform/mbed/PlatformManagerImpl.h +++ b/src/platform/mbed/PlatformManagerImpl.h @@ -96,7 +96,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener friend class Internal::CHIPService; using PlatformManager::PostEvent; - using PlatformManager::PostEventLoggingErrors; + using PlatformManager::PostEventOrDie; static PlatformManagerImpl sInstance; // ===== Members for internal use. diff --git a/src/platform/qpg/BLEManagerImpl.cpp b/src/platform/qpg/BLEManagerImpl.cpp index 13742e606d876f..ab210702860f06 100644 --- a/src/platform/qpg/BLEManagerImpl.cpp +++ b/src/platform/qpg/BLEManagerImpl.cpp @@ -199,7 +199,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) ChipLogProgress(DeviceLayer, "_OnPlatformEvent kCHIPoBLESubscribe"); HandleSubscribeReceived(event->CHIPoBLESubscribe.ConId, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_TX); connEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEventLoggingErrors(&connEstEvent); + PlatformMgr().PostEventOrDie(&connEstEvent); } break; @@ -706,7 +706,7 @@ void BLEManagerImpl::HandleDmMsg(qvCHIP_Ble_DmEvt_t * pDmEvt) ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Started; - PlatformMgr().PostEventLoggingErrors(&advChange); + PlatformMgr().PostEventOrDie(&advChange); } } break; @@ -764,7 +764,7 @@ void BLEManagerImpl::HandleDmMsg(qvCHIP_Ble_DmEvt_t * pDmEvt) event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT; break; } - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); } mFlags.Set(Flags::kAdvertisingRefreshNeeded); @@ -793,7 +793,7 @@ void BLEManagerImpl::HandleAttMsg(qvCHIP_Ble_AttEvt_t * pAttEvt) event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = pAttEvt->hdr.param; - PlatformMgr().PostEventLoggingErrors(&event); + PlatformMgr().PostEventOrDie(&event); break; } case QVCHIP_ATTC_FIND_BY_TYPE_VALUE_RSP: From 5a752dcbc4fe67443addc6eed5ad30682a74a322 Mon Sep 17 00:00:00 2001 From: Kevin Schoedel Date: Fri, 10 Sep 2021 15:08:49 -0400 Subject: [PATCH 5/5] fix P6 --- src/platform/P6/BLEManagerImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/P6/BLEManagerImpl.cpp b/src/platform/P6/BLEManagerImpl.cpp index 0ae901198ce453..5d28ec216217f8 100644 --- a/src/platform/P6/BLEManagerImpl.cpp +++ b/src/platform/P6/BLEManagerImpl.cpp @@ -556,7 +556,7 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceWrite(uint16_t conn_id, event.Type = DeviceEventType::kCHIPoBLEWriteReceived; event.CHIPoBLEWriteReceived.ConId = conn_id; event.CHIPoBLEWriteReceived.Data = buf; - CHIP_ERROR status = PlatformMgr().PostEventOrDie(&event); + CHIP_ERROR status = PlatformMgr().PostEvent(&event); if (status != CHIP_NO_ERROR) { result = WICED_BT_GATT_INTERNAL_ERROR;