Make platform PlatformManager::PostEvent() return status (#9573)
* 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.
* address review comments
* restyle
* replace PostEventLoggingErrors with PostEventOrDie
* fix P6
diff --git a/src/include/platform/PlatformManager.h b/src/include/platform/PlatformManager.h
index cceeb43..7f902b6 100644
--- a/src/include/platform/PlatformManager.h
+++ b/src/include/platform/PlatformManager.h
@@ -190,7 +190,8 @@
* 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 @@
static_cast<ImplClass *>(this)->_UnlockChipStack();
}
-inline void PlatformManager::PostEvent(const ChipDeviceEvent * event)
+inline CHIP_ERROR PlatformManager::PostEvent(const ChipDeviceEvent * event)
{
- static_cast<ImplClass *>(this)->_PostEvent(event);
+ return static_cast<ImplClass *>(this)->_PostEvent(event);
+}
+
+inline void PlatformManager::PostEventOrDie(const ChipDeviceEvent * event)
+{
+ CHIP_ERROR status = static_cast<ImplClass *>(this)->_PostEvent(event);
+ VerifyOrDieWithMsg(status == CHIP_NO_ERROR, DeviceLayer, "Failed to post event %d: %" CHIP_ERROR_FORMAT,
+ static_cast<int>(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 bac6cca..383946f 100644
--- a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp
+++ b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp
@@ -781,11 +781,14 @@
template <class ImplClass>
CHIP_ERROR GenericConfigurationManagerImpl<ImplClass>::_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 @@
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 @@
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 <class ImplClass>
diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp
index 672f404..b02aed7 100644
--- a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp
+++ b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp
@@ -109,7 +109,11 @@
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 6114df2..e388f42 100644
--- a/src/include/platform/internal/GenericPlatformManagerImpl.cpp
+++ b/src/include/platform/internal/GenericPlatformManagerImpl.cpp
@@ -207,7 +207,11 @@
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 <class ImplClass>
diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.cpp b/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.cpp
index 7848e1d..7963e6a 100644
--- a/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.cpp
+++ b/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.cpp
@@ -98,15 +98,19 @@
}
template <class ImplClass>
-void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_PostEvent(const ChipDeviceEvent * event)
+CHIP_ERROR GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_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 <class ImplClass>
@@ -218,7 +222,7 @@
{
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 24c5a65..8382a4c 100644
--- a/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.h
+++ b/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.h
@@ -68,7 +68,7 @@
void _LockChipStack(void);
bool _TryLockChipStack(void);
void _UnlockChipStack(void);
- void _PostEvent(const ChipDeviceEvent * event);
+ CHIP_ERROR _PostEvent(const ChipDeviceEvent * event);
void _RunEventLoop(void);
CHIP_ERROR _StartEventLoopTask(void);
CHIP_ERROR _StopEventLoopTask();
diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.cpp b/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.cpp
index 4195686..70b6e09 100644
--- a/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.cpp
+++ b/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.cpp
@@ -127,11 +127,12 @@
}
template <class ImplClass>
-void GenericPlatformManagerImpl_POSIX<ImplClass>::_PostEvent(const ChipDeviceEvent * event)
+CHIP_ERROR GenericPlatformManagerImpl_POSIX<ImplClass>::_PostEvent(const ChipDeviceEvent * event)
{
mChipEventQueue.Push(*event);
SystemLayerSocketsLoop().Signal(); // Trigger wake select on CHIP thread
+ return CHIP_NO_ERROR;
}
template <class ImplClass>
diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.h b/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.h
index 2916cb0..de0250e 100644
--- a/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.h
+++ b/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.h
@@ -89,7 +89,7 @@
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();
diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.cpp b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.cpp
index cea04a2..a5ce0b1 100644
--- a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.cpp
+++ b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.cpp
@@ -32,6 +32,7 @@
// from which the GenericPlatformManagerImpl_Zephyr<> template inherits.
#include <platform/internal/GenericPlatformManagerImpl.cpp>
+#include <system/SystemError.h>
#include <system/SystemLayer.h>
#define DEFAULT_MIN_SLEEP_PERIOD (60 * 60 * 24 * 30) // Month [sec]
@@ -107,15 +108,19 @@
}
template <class ImplClass>
-void GenericPlatformManagerImpl_Zephyr<ImplClass>::_PostEvent(const ChipDeviceEvent * event)
+CHIP_ERROR GenericPlatformManagerImpl_Zephyr<ImplClass>::_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<ChipDeviceEvent *>(event), K_NO_WAIT) == 0)
- SystemLayerSocketsLoop().Signal(); // Trigger wake on CHIP thread
- else
+ int status = k_msgq_put(&mChipEventQueue, const_cast<ChipDeviceEvent *>(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 <class ImplClass>
diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h
index 1ac68ad..6c4a6a2 100644
--- a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h
+++ b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.h
@@ -73,7 +73,7 @@
void _LockChipStack(void);
bool _TryLockChipStack(void);
void _UnlockChipStack(void);
- void _PostEvent(const ChipDeviceEvent * event);
+ CHIP_ERROR _PostEvent(const ChipDeviceEvent * event);
void _RunEventLoop(void);
CHIP_ERROR _StartEventLoopTask(void);
CHIP_ERROR _StopEventLoopTask();
diff --git a/src/platform/Darwin/PlatformManagerImpl.cpp b/src/platform/Darwin/PlatformManagerImpl.cpp
index bb55bb2..348ef48 100644
--- a/src/platform/Darwin/PlatformManagerImpl.cpp
+++ b/src/platform/Darwin/PlatformManagerImpl.cpp
@@ -114,12 +114,13 @@
return GenericPlatformManagerImpl<ImplClass>::_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 d0990b6..1c58a1c 100644
--- a/src/platform/Darwin/PlatformManagerImpl.h
+++ b/src/platform/Darwin/PlatformManagerImpl.h
@@ -65,7 +65,7 @@
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 e945cf4..98e9c6e 100644
--- a/src/platform/DeviceControlServer.cpp
+++ b/src/platform/DeviceControlServer.cpp
@@ -46,7 +46,11 @@
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 @@
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 f98305c..bbbf591 100644
--- a/src/platform/EFR32/BLEManagerImpl.cpp
+++ b/src/platform/EFR32/BLEManagerImpl.cpp
@@ -423,7 +423,7 @@
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 @@
{
event.Type = DeviceEventType::kCHIPoBLENotifyConfirm;
event.CHIPoBLENotifyConfirm.ConId = conId;
- PlatformMgr().PostEvent(&event);
+ err = PlatformMgr().PostEvent(&event);
}
exit:
@@ -881,7 +881,7 @@
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 @@
{
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 @@
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 @@
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 @@
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 @@
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 8087adc..7790c45 100644
--- a/src/platform/ESP32/ConnectivityManagerImpl.cpp
+++ b/src/platform/ESP32/ConnectivityManagerImpl.cpp
@@ -667,7 +667,7 @@
ChipDeviceEvent event;
event.Type = DeviceEventType::kWiFiConnectivityChange;
event.WiFiConnectivityChange.Result = kConnectivity_Established;
- PlatformMgr().PostEvent(&event);
+ PlatformMgr().PostEventOrDie(&event);
UpdateInternetConnectivityState();
}
@@ -680,7 +680,7 @@
ChipDeviceEvent event;
event.Type = DeviceEventType::kWiFiConnectivityChange;
event.WiFiConnectivityChange.Result = kConnectivity_Lost;
- PlatformMgr().PostEvent(&event);
+ PlatformMgr().PostEventOrDie(&event);
UpdateInternetConnectivityState();
}
@@ -950,7 +950,7 @@
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 @@
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 @@
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 @@
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 f6e7ef6..48ecb5e 100644
--- a/src/platform/ESP32/PlatformManagerImpl.cpp
+++ b/src/platform/ESP32/PlatformManagerImpl.cpp
@@ -192,7 +192,7 @@
}
}
- 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 3815cc8..694fae3 100644
--- a/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp
+++ b/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp
@@ -280,7 +280,7 @@
{
ChipDeviceEvent connectionEvent;
connectionEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished;
- PlatformMgr().PostEvent(&connectionEvent);
+ PlatformMgr().PostEventOrDie(&connectionEvent);
}
break;
@@ -1007,7 +1007,7 @@
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 @@
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 @@
ChipDeviceEvent event;
event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm;
event.CHIPoBLEIndicateConfirm.ConId = param->conf.conn_id;
- PlatformMgr().PostEvent(&event);
+ PlatformMgr().PostEventOrDie(&event);
}
else
@@ -1140,7 +1140,7 @@
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 @@
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 @@
ChipDeviceEvent advChange;
advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange;
advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Started;
- PlatformMgr().PostEvent(&advChange);
+ err = PlatformMgr().PostEvent(&advChange);
}
}
@@ -1340,7 +1340,7 @@
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 bd29932..09084da 100644
--- a/src/platform/ESP32/nimble/BLEManagerImpl.cpp
+++ b/src/platform/ESP32/nimble/BLEManagerImpl.cpp
@@ -279,7 +279,7 @@
{
ChipDeviceEvent connectionEvent;
connectionEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished;
- PlatformMgr().PostEvent(&connectionEvent);
+ PlatformMgr().PostEventOrDie(&connectionEvent);
}
break;
@@ -533,7 +533,7 @@
ChipDeviceEvent advChange;
advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange;
advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Started;
- PlatformMgr().PostEvent(&advChange);
+ err = PlatformMgr().PostEvent(&advChange);
}
}
}
@@ -568,7 +568,7 @@
ChipDeviceEvent advChange;
advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange;
advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Stopped;
- PlatformMgr().PostEvent(&advChange);
+ err = PlatformMgr().PostEvent(&advChange);
}
}
@@ -754,7 +754,7 @@
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:
@@ -818,7 +818,7 @@
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",
@@ -846,7 +846,7 @@
ChipDeviceEvent event;
event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm;
event.CHIPoBLEIndicateConfirm.ConId = gapEvent->notify_tx.conn_handle;
- PlatformMgr().PostEvent(&event);
+ ReturnErrorOnFailure(PlatformMgr().PostEvent(&event));
}
else
@@ -855,7 +855,7 @@
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;
@@ -924,7 +924,7 @@
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 76c0f13..69cbda3 100644
--- a/src/platform/K32W/BLEManagerImpl.cpp
+++ b/src/platform/K32W/BLEManagerImpl.cpp
@@ -403,7 +403,7 @@
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 @@
{
event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm;
event.CHIPoBLEIndicateConfirm.ConId = conId;
- PlatformMgr().PostEvent(&event);
+ err = PlatformMgr().PostEvent(&event);
}
if (err != CHIP_NO_ERROR)
@@ -908,7 +908,7 @@
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::StopAdvertising(void)
{
ble_err_t err;
+ CHIP_ERROR error = CHIP_NO_ERROR;
if (mFlags.Has(Flags::kAdvertising))
{
@@ -936,13 +937,13 @@
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 @@
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 @@
{
event.Type = DeviceEventType::kCHIPoBLESubscribe;
event.CHIPoBLESubscribe.ConId = att_wr_data->device_id;
- PlatformMgr().PostEvent(&event);
+ err = PlatformMgr().PostEvent(&event);
}
}
}
@@ -1157,7 +1158,7 @@
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 @@
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 0ff3022..9a6ea42 100644
--- a/src/platform/Linux/BLEManagerImpl.cpp
+++ b/src/platform/Linux/BLEManagerImpl.cpp
@@ -222,7 +222,7 @@
{
ChipDeviceEvent connectionEvent;
connectionEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished;
- PlatformMgr().PostEvent(&connectionEvent);
+ PlatformMgr().PostEventOrDie(&connectionEvent);
}
break;
@@ -439,7 +439,7 @@
ChipDeviceEvent event;
event.Type = DeviceEventType::kPlatformLinuxBLECentralConnected;
event.Platform.BLECentralConnected.mConnection = conId;
- PlatformMgr().PostEvent(&event);
+ PlatformMgr().PostEventOrDie(&event);
}
}
@@ -450,7 +450,7 @@
ChipDeviceEvent event;
event.Type = DeviceEventType::kPlatformLinuxBLECentralConnectFailed;
event.Platform.BLECentralConnectFailed.mError = error;
- PlatformMgr().PostEvent(&event);
+ PlatformMgr().PostEventOrDie(&event);
}
}
@@ -459,7 +459,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
ChipDeviceEvent event;
event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm;
event.CHIPoBLEIndicateConfirm.ConId = conId;
- PlatformMgr().PostEvent(&event);
+ PlatformMgr().PostEventOrDie(&event);
}
void BLEManagerImpl::DriveBLEState()
@@ -745,7 +745,7 @@
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 @@
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 @@
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 @@
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 1aa807a..4476e00 100644
--- a/src/platform/Linux/ConnectivityManagerImpl.cpp
+++ b/src/platform/Linux/ConnectivityManagerImpl.cpp
@@ -1042,7 +1042,7 @@
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 4604f34..015221b 100644
--- a/src/platform/Linux/PlatformManagerImpl.cpp
+++ b/src/platform/Linux/PlatformManagerImpl.cpp
@@ -107,7 +107,11 @@
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 bbc3ca5..8e8509a 100644
--- a/src/platform/Linux/ThreadStackManagerImpl.cpp
+++ b/src/platform/Linux/ThreadStackManagerImpl.cpp
@@ -107,13 +107,21 @@
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 @@
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 9f92385..f51a02b 100644
--- a/src/platform/LwIPEventSupport.cpp
+++ b/src/platform/LwIPEventSupport.cpp
@@ -43,9 +43,7 @@
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 140df4b..b2d5044 100644
--- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp
+++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp
@@ -89,7 +89,11 @@
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 <class ImplClass>
@@ -240,14 +244,16 @@
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 <class ImplClass>
diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp
index d73665f..63e760a 100644
--- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp
+++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp
@@ -153,7 +153,11 @@
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 6bc0365..5d28ec2 100644
--- a/src/platform/P6/BLEManagerImpl.cpp
+++ b/src/platform/P6/BLEManagerImpl.cpp
@@ -80,7 +80,10 @@
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 @@
{
ChipDeviceEvent _event;
_event.Type = DeviceEventType::kCHIPoBLEConnectionEstablished;
- PlatformMgr().PostEvent(&_event);
+ PlatformMgr().PostEventOrDie(&_event);
}
break;
@@ -428,7 +431,7 @@
ChipDeviceEvent advChange;
advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange;
advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Started;
- PlatformMgr().PostEvent(&advChange);
+ err = PlatformMgr().PostEvent(&advChange);
}
}
}
@@ -553,13 +556,18 @@
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 @@
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 @@
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 @@
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 98e7849..1dd9d94 100644
--- a/src/platform/P6/ConnectivityManagerImpl.cpp
+++ b/src/platform/P6/ConnectivityManagerImpl.cpp
@@ -611,7 +611,7 @@
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 @@
ChipDeviceEvent event;
event.Type = DeviceEventType::kInterfaceIpAddressChanged;
event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV6_Assigned;
- PlatformMgr().PostEvent(&event);
+ PlatformMgr().PostEventOrDie(&event);
}
}
}
@@ -642,7 +642,7 @@
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 b5196cc..0ad70bd 100644
--- a/src/platform/Zephyr/BLEManagerImpl.cpp
+++ b/src/platform/Zephyr/BLEManagerImpl.cpp
@@ -285,7 +285,7 @@
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 @@
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 @@
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 @@
{
ChipDeviceEvent conEstEvent;
conEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished;
- PlatformMgr().PostEvent(&conEstEvent);
+ ReturnErrorOnFailure(PlatformMgr().PostEvent(&conEstEvent));
}
}
else
@@ -764,7 +764,7 @@
event.Type = DeviceEventType::kPlatformZephyrBleOutOfBuffersEvent;
}
- PlatformMgr().PostEvent(&event);
+ PlatformMgr().PostEventOrDie(&event);
return len;
}
@@ -782,7 +782,7 @@
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 @@
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 @@
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 @@
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 38f2ec2..8f8905c 100644
--- a/src/platform/cc13x2_26x2/BLEManagerImpl.cpp
+++ b/src/platform/cc13x2_26x2/BLEManagerImpl.cpp
@@ -241,7 +241,7 @@
connEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished;
- PlatformMgr().PostEvent(&connEstEvent);
+ PlatformMgr().PostEventOrDie(&connEstEvent);
}
break;
@@ -900,7 +900,7 @@
event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm;
event.CHIPoBLEIndicateConfirm.ConId = connHandle;
- PlatformMgr().PostEvent(&event);
+ PlatformMgr().PostEventOrDie(&event);
dealloc = TRUE;
}
@@ -984,7 +984,7 @@
// Post event to CHIP
event.CHIPoBLESubscribe.ConId = (void *) connHandle;
}
- PlatformMgr().PostEvent(&event);
+ PlatformMgr().PostEventOrDie(&event);
}
break;
@@ -1144,7 +1144,7 @@
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 @@
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 7e72637..0483a4c 100644
--- a/src/platform/fake/PlatformManagerImpl.h
+++ b/src/platform/fake/PlatformManagerImpl.h
@@ -50,7 +50,7 @@
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 7b8733b..e297d26 100644
--- a/src/platform/mbed/BLEManagerImpl.cpp
+++ b/src/platform/mbed/BLEManagerImpl.cpp
@@ -184,7 +184,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 c2a2456..81edfda 100644
--- a/src/platform/mbed/ConnectivityManagerImpl.cpp
+++ b/src/platform/mbed/ConnectivityManagerImpl.cpp
@@ -246,7 +246,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 66235a1..2ddb6e2 100644
--- a/src/platform/mbed/PlatformManagerImpl.cpp
+++ b/src/platform/mbed/PlatformManagerImpl.cpp
@@ -106,7 +106,7 @@
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 @@
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 ad9cff5..ff5c04e 100644
--- a/src/platform/mbed/PlatformManagerImpl.h
+++ b/src/platform/mbed/PlatformManagerImpl.h
@@ -77,7 +77,7 @@
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 @@
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 3133972..ab21070 100644
--- a/src/platform/qpg/BLEManagerImpl.cpp
+++ b/src/platform/qpg/BLEManagerImpl.cpp
@@ -199,7 +199,7 @@
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 @@
ChipDeviceEvent advChange;
advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange;
advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Stopped;
- PlatformMgr().PostEvent(&advChange);
+ err = PlatformMgr().PostEvent(&advChange);
}
}
@@ -612,7 +612,7 @@
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 @@
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 @@
ChipDeviceEvent advChange;
advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange;
advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Started;
- PlatformMgr().PostEvent(&advChange);
+ PlatformMgr().PostEventOrDie(&advChange);
}
}
break;
@@ -764,7 +764,7 @@
event.CHIPoBLEConnectionError.Reason = BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT;
break;
}
- PlatformMgr().PostEvent(&event);
+ PlatformMgr().PostEventOrDie(&event);
}
mFlags.Set(Flags::kAdvertisingRefreshNeeded);
@@ -793,7 +793,7 @@
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: