Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[K32W] Sync button push with cluster state #8761

Merged
merged 3 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions examples/lighting-app/k32w/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ CHIP_ERROR AppTask::Init()

sLightLED.Init(LIGHT_STATE_LED);
sLightLED.Set(LightingMgr().IsTurnedOff());
UpdateClusterState();

/* intialize the Keyboard and button press calback */
KBD_Init(KBD_Callback);
Expand Down Expand Up @@ -565,6 +566,11 @@ void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor)
K32W_LOG("Turn off Action has been initiated")
}

if (aActor == AppEvent::kEventType_Button)
{
sAppTask.mSyncClusterToButtonAction = true;
}

sAppTask.mFunction = kFunctionTurnOnTurnOff;
}

Expand All @@ -583,6 +589,12 @@ void AppTask::ActionCompleted(LightingManager::Action_t aAction)
sLightLED.Set(false);
}

if (sAppTask.mSyncClusterToButtonAction)
{
sAppTask.UpdateClusterState();
sAppTask.mSyncClusterToButtonAction = false;
}

sAppTask.mFunction = kFunction_NoneSelected;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/lighting-app/k32w/main/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ class AppTask
kFunction_Invalid
} Function;

Function_t mFunction;
bool mResetTimerActive;
Function_t mFunction = kFunction_NoneSelected;
bool mResetTimerActive = false;
bool mSyncClusterToButtonAction = false;

static AppTask sAppTask;
};
Expand Down
12 changes: 12 additions & 0 deletions examples/lock-app/k32w/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ CHIP_ERROR AppTask::Init()

sLockLED.Init(LOCK_STATE_LED);
sLockLED.Set(!BoltLockMgr().IsUnlocked());
UpdateClusterState();

/* intialize the Keyboard and button press calback */
KBD_Init(KBD_Callback);
Expand Down Expand Up @@ -570,6 +571,11 @@ void AppTask::ActionInitiated(BoltLockManager::Action_t aAction, int32_t aActor)
K32W_LOG("Unlock Action has been initiated")
}

if (aActor == AppEvent::kEventType_Button)
{
sAppTask.mSyncClusterToButtonAction = true;
}

sAppTask.mFunction = kFunctionLockUnlock;
sLockLED.Blink(50, 50);
}
Expand All @@ -590,6 +596,12 @@ void AppTask::ActionCompleted(BoltLockManager::Action_t aAction)
sLockLED.Set(false);
}

if (sAppTask.mSyncClusterToButtonAction)
{
sAppTask.UpdateClusterState();
sAppTask.mSyncClusterToButtonAction = false;
}

sAppTask.mFunction = kFunction_NoneSelected;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/lock-app/k32w/main/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ class AppTask
kFunction_Invalid
} Function;

Function_t mFunction;
bool mResetTimerActive;
Function_t mFunction = kFunction_NoneSelected;
bool mResetTimerActive = false;
bool mSyncClusterToButtonAction = false;

static AppTask sAppTask;
};
Expand Down