diff --git a/src/include/platform/PlatformManager.h b/src/include/platform/PlatformManager.h index cceeb432027a2d..7f902b6a9c8829 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); + void PostEventOrDie(const ChipDeviceEvent * event); void DispatchEvent(const ChipDeviceEvent * event); CHIP_ERROR StartChipTimer(uint32_t durationMS); @@ -354,9 +355,16 @@ 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 void PlatformManager::PostEventOrDie(const ChipDeviceEvent * event) +{ + CHIP_ERROR status = static_cast(this)->_PostEvent(event); + 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/include/platform/internal/GenericConfigurationManagerImpl.cpp b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp index bac6cca73583ee..383946f9bf58c2 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; - 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; - 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/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 6114df23b82e24..e388f424eb700c 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl.cpp +++ b/src/include/platform/internal/GenericPlatformManagerImpl.cpp @@ -207,7 +207,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 7848e1dd8ce1e5..7963e6a3d026ad 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); SystemLayerSocketsLoop().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] @@ -107,15 +108,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) - SystemLayerSocketsLoop().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); + } + SystemLayerSocketsLoop().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 e945cf480861c5..98e9c6e5b4f789 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,8 +72,7 @@ CHIP_ERROR DeviceControlServer::CommissioningComplete() ChipDeviceEvent event; event.Type = DeviceEventType::kCommissioningComplete; event.CommissioningComplete.status = CHIP_NO_ERROR; - 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/EFR32/BLEManagerImpl.cpp b/src/platform/EFR32/BLEManagerImpl.cpp index f98305c4a8c3e6..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().PostEvent(&connEstEvent); + PlatformMgr().PostEventOrDie(&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().PostEventOrDie(&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().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().PostEvent(&event); + PlatformMgr().PostEventOrDie(&event); } } diff --git a/src/platform/ESP32/ConnectivityManagerImpl.cpp b/src/platform/ESP32/ConnectivityManagerImpl.cpp index 8087adcd1e5f83..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().PostEvent(&event); + PlatformMgr().PostEventOrDie(&event); UpdateInternetConnectivityState(); } @@ -680,7 +680,7 @@ void ConnectivityManagerImpl::OnStationDisconnected() ChipDeviceEvent event; event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Lost; - PlatformMgr().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&event); + PlatformMgr().PostEventOrDie(&event); } void ConnectivityManagerImpl::RefreshMessageLayer(void) {} diff --git a/src/platform/ESP32/PlatformManagerImpl.cpp b/src/platform/ESP32/PlatformManagerImpl.cpp index f6e7ef64bbf216..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.PostEvent(&event); + sInstance.PostEventOrDie(&event); } } // namespace DeviceLayer diff --git a/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp b/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp index 3815cc8d2687d6..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().PostEvent(&connectionEvent); + PlatformMgr().PostEventOrDie(&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().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().PostEvent(&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().PostEvent(&event); + PlatformMgr().PostEventOrDie(&event); ChipDeviceEvent disconnectEvent; disconnectEvent.Type = DeviceEventType::kCHIPoBLEConnectionClosed; - PlatformMgr().PostEvent(&disconnectEvent); + PlatformMgr().PostEventOrDie(&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 21c5367ac08550..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().PostEvent(&connectionEvent); + PlatformMgr().PostEventOrDie(&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 76c0f13c6fd43e..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().PostEvent(&connEstEvent); + PlatformMgr().PostEventOrDie(&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().PostEventOrDie(&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 0ff302258cab93..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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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 f2a82511b0dc64..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().PostEvent(&event); + PlatformMgr().PostEventOrDie(&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..8e8509ae47870b 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,9 +220,7 @@ CHIP_ERROR ThreadStackManagerImpl::_SetThreadProvision(ByteSpan netInfo) ChipDeviceEvent event; event.Type = DeviceEventType::kServiceProvisioningChange; event.ServiceProvisioningChange.IsServiceProvisioned = true; - PlatformMgr().PostEvent(&event); - - return CHIP_NO_ERROR; + return PlatformMgr().PostEvent(&event); } CHIP_ERROR ThreadStackManagerImpl::_GetThreadProvision(ByteSpan & netInfo) 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..b2d504477011a5 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 @@ -240,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; - PlatformMgr().PostEvent(&event); - - return MapOpenThreadError(otErr); + return PlatformMgr().PostEvent(&event); } template 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 6bc03659006835..5d28ec216217f8 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().PostEventOrDie(&_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().PostEvent(&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 98e7849e1ea7f4..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().PostEvent(&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().PostEvent(&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().PostEvent(&event); + PlatformMgr().PostEventOrDie(&event); if (haveIPv4Conn != hadIPv4Conn) { diff --git a/src/platform/Zephyr/BLEManagerImpl.cpp b/src/platform/Zephyr/BLEManagerImpl.cpp index b5196ccba871f2..0ad70bdc7cc349 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().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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&event); + PlatformMgr().PostEventOrDie(&event); exit: PlatformMgr().UnlockChipStack(); diff --git a/src/platform/cc13x2_26x2/BLEManagerImpl.cpp b/src/platform/cc13x2_26x2/BLEManagerImpl.cpp index 38f2ec2a0d39ac..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().PostEvent(&connEstEvent); + PlatformMgr().PostEventOrDie(&connEstEvent); } break; @@ -900,7 +900,7 @@ void BLEManagerImpl::ProcessEvtHdrMsg(QueuedEvt_t * pMsg) event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; event.CHIPoBLEIndicateConfirm.ConId = connHandle; - PlatformMgr().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&event); + PlatformMgr().PostEventOrDie(&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 7b8733bc4a6836..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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&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().PostEvent(&connEstEvent); + PlatformMgrImpl().PostEventOrDie(&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 66235a1437e233..2ddb6e2a7efb06 100644 --- a/src/platform/mbed/PlatformManagerImpl.cpp +++ b/src/platform/mbed/PlatformManagerImpl.cpp @@ -106,7 +106,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(); @@ -117,7 +117,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..ff5c04e558e5e9 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::PostEventOrDie; static PlatformManagerImpl sInstance; // ===== Members for internal use. diff --git a/src/platform/qpg/BLEManagerImpl.cpp b/src/platform/qpg/BLEManagerImpl.cpp index 3133972ec7ec25..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().PostEvent(&connEstEvent); + PlatformMgr().PostEventOrDie(&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().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().PostEvent(&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().PostEvent(&event); + PlatformMgr().PostEventOrDie(&event); break; } case QVCHIP_ATTC_FIND_BY_TYPE_VALUE_RSP: