From 507201aedc633a4bfd5b16cbe287c510230e4b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Josefsen?= Date: Thu, 9 Jun 2022 14:56:26 +0200 Subject: [PATCH 1/2] PostEvents now called from ScheduleWork --- examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp | 8 +++++--- examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index 2cb5475fcdf4f9..d82b43a08d31c3 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -379,8 +379,10 @@ void AppTask::DispatchEvent(AppEvent * aEvent) case AppEvent::kEventType_ButtonLeft: if (AppEvent::kAppEventButtonType_Clicked == aEvent->ButtonEvent.Type) { - // Post event for demonstration purposes - sAppTask.PostEvents(); + // Post event for demonstration purposes, we must ensure that the + // LogEvent is called in the right context which is the Matter mainloop + // thru ScheduleWork() + chip::DeviceLayer::PlatformMgr().ScheduleWork(sAppTask.PostEvents, reinterpret_cast(nullptr)); // Toggle BLE advertisements if (!ConnectivityMgr().IsBLEAdvertisingEnabled()) @@ -608,7 +610,7 @@ void AppTask::UpdateCluster(intptr_t context) } } -void AppTask::PostEvents() +void AppTask::PostEvents(intptr_t context) { // Example on posting events - here we post the general fault event on endpoints with PCC Server enabled for (auto endpoint : EnabledEndpointsWithServerCluster(PumpConfigurationAndControl::Id)) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h index 9e0d3e84d7071a..7fd3f38ff6f0d5 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h @@ -64,7 +64,7 @@ class AppTask static void ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events); static void ButtonRightEventHandler(Button_Handle handle, Button_EventMask events); static void TimerEventHandler(void * p_context); - static void PostEvents(); + static void PostEvents(intptr_t context); enum Function_t { From 3b6bb5e584f9d70cbde27d19ba7cc7352bbe610d Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 9 Jun 2022 13:25:53 +0000 Subject: [PATCH 2/2] Restyled by whitespace --- examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index d82b43a08d31c3..4aed41ba0cb718 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -379,8 +379,8 @@ void AppTask::DispatchEvent(AppEvent * aEvent) case AppEvent::kEventType_ButtonLeft: if (AppEvent::kAppEventButtonType_Clicked == aEvent->ButtonEvent.Type) { - // Post event for demonstration purposes, we must ensure that the - // LogEvent is called in the right context which is the Matter mainloop + // Post event for demonstration purposes, we must ensure that the + // LogEvent is called in the right context which is the Matter mainloop // thru ScheduleWork() chip::DeviceLayer::PlatformMgr().ScheduleWork(sAppTask.PostEvents, reinterpret_cast(nullptr));