diff --git a/examples/lighting-app/qpg/src/AppTask.cpp b/examples/lighting-app/qpg/src/AppTask.cpp index 13e78387cc4a99..25b89e41b29ddc 100644 --- a/examples/lighting-app/qpg/src/AppTask.cpp +++ b/examples/lighting-app/qpg/src/AppTask.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -44,6 +45,8 @@ #include #include +using namespace ::chip; +using namespace ::chip::app; using namespace ::chip::TLV; using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; @@ -55,6 +58,7 @@ using namespace ::chip::DeviceLayer; #define APP_TASK_STACK_SIZE (3 * 1024) #define APP_TASK_PRIORITY 2 #define APP_EVENT_QUEUE_SIZE 10 +#define QPG_LIGHT_ENDPOINT_ID (1) namespace { TaskHandle_t sAppTaskHandle; @@ -587,23 +591,17 @@ void AppTask::DispatchEvent(AppEvent * aEvent) */ void AppTask::UpdateClusterState(void) { - uint8_t newValue; - ChipLogProgress(NotSpecified, "UpdateClusterState"); - // write the new on/off value - newValue = LightingMgr().IsTurnedOn(); - EmberAfStatus status = - emberAfWriteAttribute(1, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &newValue, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + // Write the new on/off value + EmberAfStatus status = Clusters::OnOff::Attributes::OnOff::Set(QPG_LIGHT_ENDPOINT_ID, LightingMgr().IsTurnedOn()); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: updating on/off %x", status); } - newValue = LightingMgr().GetLevel(); - status = emberAfWriteAttribute(1, ZCL_LEVEL_CONTROL_CLUSTER_ID, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, (uint8_t *) &newValue, - ZCL_INT8U_ATTRIBUTE_TYPE); - + // Write new level value + status = Clusters::LevelControl::Attributes::CurrentLevel::Set(QPG_LIGHT_ENDPOINT_ID, LightingMgr().GetLevel()); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: updating level %x", status); diff --git a/examples/lock-app/qpg/src/AppTask.cpp b/examples/lock-app/qpg/src/AppTask.cpp index 86a28d5e9bb863..779585d6a9074f 100644 --- a/examples/lock-app/qpg/src/AppTask.cpp +++ b/examples/lock-app/qpg/src/AppTask.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -41,6 +42,8 @@ #include #include +using namespace ::chip; +using namespace ::chip::app; using namespace chip::TLV; using namespace chip::Credentials; using namespace chip::DeviceLayer; @@ -54,6 +57,7 @@ using namespace chip::DeviceLayer; #define APP_TASK_STACK_SIZE (3 * 1024) #define APP_TASK_PRIORITY 2 #define APP_EVENT_QUEUE_SIZE 10 +#define QPG_LOCK_ENDPOINT_ID (1) namespace { TaskHandle_t sAppTaskHandle; @@ -538,13 +542,10 @@ void AppTask::DispatchEvent(AppEvent * aEvent) */ void AppTask::UpdateClusterState(void) { - uint8_t newValue = !BoltLockMgr().IsUnlocked(); - ChipLogProgress(NotSpecified, "UpdateClusterState"); // write the new on/off value - EmberAfStatus status = - emberAfWriteAttribute(1, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &newValue, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + EmberAfStatus status = Clusters::OnOff::Attributes::OnOff::Set(QPG_LOCK_ENDPOINT_ID, !BoltLockMgr().IsUnlocked()); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: updating on/off %x", status);