diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index 2cb5475fcdf4f9..4aed41ba0cb718 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 {