Skip to content

Commit

Permalink
[pump] PostEvents now called from ScheduleWork (project-chip#19379)
Browse files Browse the repository at this point in the history
* PostEvents now called from ScheduleWork

* Fixed whitespace from restyle
  • Loading branch information
ReneJosefsen authored and rochaferraz committed Jun 15, 2022
1 parent 2b1e023 commit 31914d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<intptr_t>(nullptr));

// Toggle BLE advertisements
if (!ConnectivityMgr().IsBLEAdvertisingEnabled())
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 31914d5

Please sign in to comment.