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

[QPG] LED handling switched from polling to event-based #23526

Merged
merged 11 commits into from
Nov 9, 2022
Next Next commit
Switched to callbacks
adamb-q authored and tima-q committed Nov 8, 2022

Verified

This commit was created on github.com and signed with GitHub’s verified signature.
commit 6d5de867d19beb4bd6664cc33281b164181e4c81
21 changes: 19 additions & 2 deletions examples/lighting-app/qpg/src/AppTask.cpp
Original file line number Diff line number Diff line change
@@ -260,6 +260,8 @@ CHIP_ERROR AppTask::Init()
{
CHIP_ERROR err = CHIP_NO_ERROR;

PlatformMgr().AddEventHandler(MatterEventHandler, 0);

ChipLogProgress(NotSpecified, "Current Software Version: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);

// Init ZCL Data Model and start server
@@ -317,8 +319,8 @@ void AppTask::AppTaskMain(void * pvParameter)
// when the CHIP task is busy (e.g. with a long crypto operation).
if (PlatformMgr().TryLockChipStack())
{
sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned();
sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled();
// sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned();
// sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled();
sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0);
PlatformMgr().UnlockChipStack();
}
@@ -621,3 +623,18 @@ void AppTask::UpdateClusterState(void)
ChipLogError(NotSpecified, "ERR: updating level %x", status);
}
}

void AppTask::MatterEventHandler(const ChipDeviceEvent * event, intptr_t)
{
if (event->Type == DeviceEventType::kServiceProvisioningChange && event->ServiceProvisioningChange.IsServiceProvisioned)
{
if (event->ServiceProvisioningChange.IsServiceProvisioned)
{
sIsThreadProvisioned = true;
}
else
{
sIsThreadProvisioned = false;
}
}
}