diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index 4776cc0b773fab..25e449a0166555 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -50,6 +50,9 @@ #define APP_TASK_PRIORITY 4 #define APP_EVENT_QUEUE_SIZE 10 +#define PCC_CLUSTER_ENDPOINT 1 +#define ONOFF_CLUSTER_ENDPOINT 1 + using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; using namespace ::chip::app::Clusters; @@ -279,7 +282,7 @@ void AppTask::ActionInitiated(PumpManager::Action_t aAction, int32_t aActor) LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); } -void AppTask::ActionCompleted(PumpManager::Action_t aAction) +void AppTask::ActionCompleted(PumpManager::Action_t aAction, int32_t aActor) { // if the action has been completed by the pump, update the pump trait. // Turn on the pump state LED if in a STARTED state OR @@ -300,6 +303,10 @@ void AppTask::ActionCompleted(PumpManager::Action_t aAction) LED_stopBlinking(sAppRedHandle); LED_setOff(sAppRedHandle); } + if (aActor == AppEvent::kEventType_ButtonLeft) + { + sAppTask.UpdateClusterState(); + } } void AppTask::DispatchEvent(AppEvent * aEvent) @@ -368,102 +375,102 @@ void AppTask::UpdateClusterState() ChipLogProgress(NotSpecified, "UpdateClusterState"); - // write the new values + // Write the new values bool onOffState = !PumpMgr().IsStopped(); - status = OnOff::Attributes::OnOff::Set(1, onOffState); + status = OnOff::Attributes::OnOff::Set(ONOFF_CLUSTER_ENDPOINT, onOffState); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating On/Off state %" PRIx8, status); } int16_t maxPressure = PumpMgr().GetMaxPressure(); - status = PumpConfigurationAndControl::Attributes::MaxPressure::Set(1, maxPressure); + status = PumpConfigurationAndControl::Attributes::MaxPressure::Set(PCC_CLUSTER_ENDPOINT, maxPressure); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxPressure %" PRIx8, status); } uint16_t maxSpeed = PumpMgr().GetMaxSpeed(); - status = PumpConfigurationAndControl::Attributes::MaxSpeed::Set(1, maxSpeed); + status = PumpConfigurationAndControl::Attributes::MaxSpeed::Set(PCC_CLUSTER_ENDPOINT, maxSpeed); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxSpeed %" PRIx8, status); } uint16_t maxFlow = PumpMgr().GetMaxFlow(); - status = PumpConfigurationAndControl::Attributes::MaxFlow::Set(1, maxFlow); + status = PumpConfigurationAndControl::Attributes::MaxFlow::Set(PCC_CLUSTER_ENDPOINT, maxFlow); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxFlow %" PRIx8, status); } int16_t minConstPress = PumpMgr().GetMinConstPressure(); - status = PumpConfigurationAndControl::Attributes::MinConstPressure::Set(1, minConstPress); + status = PumpConfigurationAndControl::Attributes::MinConstPressure::Set(PCC_CLUSTER_ENDPOINT, minConstPress); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinConstPressure %" PRIx8, status); } int16_t maxConstPress = PumpMgr().GetMaxConstPressure(); - status = PumpConfigurationAndControl::Attributes::MaxConstPressure::Set(1, maxConstPress); + status = PumpConfigurationAndControl::Attributes::MaxConstPressure::Set(PCC_CLUSTER_ENDPOINT, maxConstPress); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxConstPressure %" PRIx8, status); } int16_t minCompPress = PumpMgr().GetMinCompPressure(); - status = PumpConfigurationAndControl::Attributes::MinCompPressure::Set(1, minCompPress); + status = PumpConfigurationAndControl::Attributes::MinCompPressure::Set(PCC_CLUSTER_ENDPOINT, minCompPress); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinCompPressure %" PRIx8, status); } int16_t maxCompPress = PumpMgr().GetMaxCompPressure(); - status = PumpConfigurationAndControl::Attributes::MaxCompPressure::Set(1, maxCompPress); + status = PumpConfigurationAndControl::Attributes::MaxCompPressure::Set(PCC_CLUSTER_ENDPOINT, maxCompPress); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxCompPressure %" PRIx8, status); } uint16_t minConstSpeed = PumpMgr().GetMinConstSpeed(); - status = PumpConfigurationAndControl::Attributes::MinConstSpeed::Set(1, minConstSpeed); + status = PumpConfigurationAndControl::Attributes::MinConstSpeed::Set(PCC_CLUSTER_ENDPOINT, minConstSpeed); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinConstSpeed %" PRIx8, status); } uint16_t maxConstSpeed = PumpMgr().GetMaxConstSpeed(); - status = PumpConfigurationAndControl::Attributes::MaxConstSpeed::Set(1, maxConstSpeed); + status = PumpConfigurationAndControl::Attributes::MaxConstSpeed::Set(PCC_CLUSTER_ENDPOINT, maxConstSpeed); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxConstSpeed %" PRIx8, status); } uint16_t minConstFlow = PumpMgr().GetMinConstFlow(); - status = PumpConfigurationAndControl::Attributes::MinConstFlow::Set(1, minConstFlow); + status = PumpConfigurationAndControl::Attributes::MinConstFlow::Set(PCC_CLUSTER_ENDPOINT, minConstFlow); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinConstFlow %" PRIx8, status); } uint16_t maxConstFlow = PumpMgr().GetMaxConstFlow(); - status = PumpConfigurationAndControl::Attributes::MaxConstFlow::Set(1, maxConstFlow); + status = PumpConfigurationAndControl::Attributes::MaxConstFlow::Set(PCC_CLUSTER_ENDPOINT, maxConstFlow); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxConstFlow %" PRIx8, status); } int16_t minConstTemp = PumpMgr().GetMinConstTemp(); - status = PumpConfigurationAndControl::Attributes::MinConstTemp::Set(1, minConstTemp); + status = PumpConfigurationAndControl::Attributes::MinConstTemp::Set(PCC_CLUSTER_ENDPOINT, minConstTemp); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MinConstTemp %" PRIx8, status); } int16_t maxConstTemp = PumpMgr().GetMaxConstTemp(); - status = PumpConfigurationAndControl::Attributes::MaxConstTemp::Set(1, maxConstTemp); + status = PumpConfigurationAndControl::Attributes::MaxConstTemp::Set(PCC_CLUSTER_ENDPOINT, maxConstTemp); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: Updating MaxConstTemp %" PRIx8, status); diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp index 73e638fcceb348..28af445b25caa9 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp @@ -82,14 +82,14 @@ bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction) if (mState == kState_StartCompleted && aAction == STOP_ACTION) { action_initiated = true; - - new_state = kState_StopInitiated; + mCurrentActor = aActor; + new_state = kState_StopInitiated; } else if (mState == kState_StopCompleted && aAction == START_ACTION) { action_initiated = true; - - new_state = kState_StartInitiated; + mCurrentActor = aActor; + new_state = kState_StartInitiated; } if (action_initiated) @@ -113,7 +113,6 @@ bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction) mActionInitiated_CB(aAction, aActor); } } - return action_initiated; } @@ -188,7 +187,7 @@ void PumpManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent) { if (pump->mActionCompleted_CB) { - pump->mActionCompleted_CB(actionCompleted); + pump->mActionCompleted_CB(actionCompleted, pump->mCurrentActor); } if (pump->mAutoRestart && actionCompleted == STOP_ACTION) diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h index 65fb71df49adc9..11e402ebe3bcb9 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/AppTask.h @@ -47,7 +47,7 @@ class AppTask int Init(); static void ActionInitiated(PumpManager::Action_t aAction, int32_t aActor); - static void ActionCompleted(PumpManager::Action_t aAction); + static void ActionCompleted(PumpManager::Action_t aAction, int32_t aActor); void DispatchEvent(AppEvent * event); diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/PumpManager.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/PumpManager.h index 62988216fec1fb..ea742c22acb765 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/PumpManager.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/PumpManager.h @@ -68,7 +68,7 @@ class PumpManager int16_t GetMaxConstTemp(); typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); - typedef void (*Callback_fn_completed)(Action_t); + typedef void (*Callback_fn_completed)(Action_t, int32_t aActor); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); private: @@ -82,6 +82,7 @@ class PumpManager uint32_t mAutoStartDuration; bool mAutoStartTimerArmed; TimerHandle_t mTimerHandle; + int32_t mCurrentActor; void CancelTimer(void); void PumpTimer(uint32_t aTimeoutMs); diff --git a/examples/pump-app/nrfconnect/main/AppTask.cpp b/examples/pump-app/nrfconnect/main/AppTask.cpp index 844bf837042268..c6e3e48f992cee 100644 --- a/examples/pump-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-app/nrfconnect/main/AppTask.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -44,6 +45,9 @@ #define BUTTON_PUSH_EVENT 1 #define BUTTON_RELEASE_EVENT 0 +#define PCC_CLUSTER_ENDPOINT 1 +#define ONOFF_CLUSTER_ENDPOINT 1 + LOG_MODULE_DECLARE(app); K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), APP_EVENT_QUEUE_SIZE, alignof(AppEvent)); @@ -60,6 +64,7 @@ static k_timer sFunctionTimer; using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; +using namespace ::chip::app::Clusters; AppTask AppTask::sAppTask; @@ -505,13 +510,108 @@ void AppTask::DispatchEvent(AppEvent * aEvent) void AppTask::UpdateClusterState() { - uint8_t newValue = !PumpMgr().IsStopped(); + EmberStatus status; + + ChipLogProgress(NotSpecified, "UpdateClusterState"); + + // Write the new values + + bool onOffState = !PumpMgr().IsStopped(); + + status = OnOff::Attributes::OnOff::Set(ONOFF_CLUSTER_ENDPOINT, onOffState); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating On/Off state %" PRIx8, status); + } + + int16_t maxPressure = PumpMgr().GetMaxPressure(); + status = PumpConfigurationAndControl::Attributes::MaxPressure::Set(PCC_CLUSTER_ENDPOINT, maxPressure); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxPressure %" PRIx8, status); + } + + uint16_t maxSpeed = PumpMgr().GetMaxSpeed(); + status = PumpConfigurationAndControl::Attributes::MaxSpeed::Set(PCC_CLUSTER_ENDPOINT, maxSpeed); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxSpeed %" PRIx8, status); + } + + uint16_t maxFlow = PumpMgr().GetMaxFlow(); + status = PumpConfigurationAndControl::Attributes::MaxFlow::Set(PCC_CLUSTER_ENDPOINT, maxFlow); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxFlow %" PRIx8, status); + } + + int16_t minConstPress = PumpMgr().GetMinConstPressure(); + status = PumpConfigurationAndControl::Attributes::MinConstPressure::Set(PCC_CLUSTER_ENDPOINT, minConstPress); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstPressure %" PRIx8, status); + } + + int16_t maxConstPress = PumpMgr().GetMaxConstPressure(); + status = PumpConfigurationAndControl::Attributes::MaxConstPressure::Set(PCC_CLUSTER_ENDPOINT, maxConstPress); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstPressure %" PRIx8, status); + } + + int16_t minCompPress = PumpMgr().GetMinCompPressure(); + status = PumpConfigurationAndControl::Attributes::MinCompPressure::Set(PCC_CLUSTER_ENDPOINT, minCompPress); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinCompPressure %" PRIx8, status); + } + + int16_t maxCompPress = PumpMgr().GetMaxCompPressure(); + status = PumpConfigurationAndControl::Attributes::MaxCompPressure::Set(PCC_CLUSTER_ENDPOINT, maxCompPress); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxCompPressure %" PRIx8, status); + } + + uint16_t minConstSpeed = PumpMgr().GetMinConstSpeed(); + status = PumpConfigurationAndControl::Attributes::MinConstSpeed::Set(PCC_CLUSTER_ENDPOINT, minConstSpeed); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstSpeed %" PRIx8, status); + } + + uint16_t maxConstSpeed = PumpMgr().GetMaxConstSpeed(); + status = PumpConfigurationAndControl::Attributes::MaxConstSpeed::Set(PCC_CLUSTER_ENDPOINT, maxConstSpeed); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstSpeed %" PRIx8, status); + } + + uint16_t minConstFlow = PumpMgr().GetMinConstFlow(); + status = PumpConfigurationAndControl::Attributes::MinConstFlow::Set(PCC_CLUSTER_ENDPOINT, minConstFlow); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstFlow %" PRIx8, status); + } + + uint16_t maxConstFlow = PumpMgr().GetMaxConstFlow(); + status = PumpConfigurationAndControl::Attributes::MaxConstFlow::Set(PCC_CLUSTER_ENDPOINT, maxConstFlow); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MaxConstFlow %" PRIx8, status); + } + + int16_t minConstTemp = PumpMgr().GetMinConstTemp(); + status = PumpConfigurationAndControl::Attributes::MinConstTemp::Set(PCC_CLUSTER_ENDPOINT, minConstTemp); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: Updating MinConstTemp %" PRIx8, status); + } - // write the new on/off value - EmberAfStatus status = emberAfWriteAttribute(1, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, &newValue, - ZCL_BOOLEAN_ATTRIBUTE_TYPE); + int16_t maxConstTemp = PumpMgr().GetMaxConstTemp(); + status = PumpConfigurationAndControl::Attributes::MaxConstTemp::Set(PCC_CLUSTER_ENDPOINT, maxConstTemp); if (status != EMBER_ZCL_STATUS_SUCCESS) { - LOG_ERR("Updating on/off %x", status); + ChipLogError(NotSpecified, "ERR: Updating MaxConstTemp %" PRIx8, status); } } diff --git a/examples/pump-app/nrfconnect/main/PumpManager.cpp b/examples/pump-app/nrfconnect/main/PumpManager.cpp index 7e0c9482305df9..274ef8ff812886 100644 --- a/examples/pump-app/nrfconnect/main/PumpManager.cpp +++ b/examples/pump-app/nrfconnect/main/PumpManager.cpp @@ -187,3 +187,133 @@ void PumpManager::PumpStartTimerEventHandler(AppEvent * aEvent) } } } + +int16_t PumpManager::GetMaxPressure() +{ + // 1.6.1. MaxPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return 2000.0 kPa as Max Pressure + return 20000; +} + +uint16_t PumpManager::GetMaxSpeed() +{ + // 1.6.2. MaxSpeed Attribute + // Range 0 RPM to 65534 RPM (steps of 1 RPM) + // 65535 is invalid value - perhaps 'null' + + // Return 1000 RPM as MaxSpeed + return 1000; +} + +uint16_t PumpManager::GetMaxFlow() +{ + // 1.6.3. MaxFlow Attribute + // Range 0 m3/h to 6553.4 m3/h (steps of 0.1 m3/h) + // 6553.5 m3/h is invalid value - perhaps 'null' + + // Return 200.0 m3/h as MaxFlow + return 2000; +} + +int16_t PumpManager::GetMinConstPressure() +{ + // 1.6.4. MinConstPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return -100.0 kPa as MinConstPressure + return -1000; +} + +int16_t PumpManager::GetMaxConstPressure() +{ + // 1.6.5. MaxConstPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return 100.0 kPa as MaxConstPressure + return 1000; +} + +int16_t PumpManager::GetMinCompPressure() +{ + // 1.6.6. MinCompPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return -20.0 kPa as MinCompPressure + return -200; +} + +int16_t PumpManager::GetMaxCompPressure() +{ + // 1.6.7. MaxCompPressure Attribute + // Range -3276.7 kPa to 3276.7 kPa (steps of 0.1 kPa) + // -3276.8 is invalid value - perhaps 'null' + + // Return 20.0 kPa as MaxCompPressure + return 200; +} + +uint16_t PumpManager::GetMinConstSpeed() +{ + // 1.6.8. MinConstSpeed Attribute + // Range 0 to 65534 RPM (steps of 1 RPM) + // 65535 RPM is invalid valud - perhaps 'null' + + // Return 200 RPM as MinConstSpeed + return 200; +} + +uint16_t PumpManager::GetMaxConstSpeed() +{ + // 1.6.9. MaxConstSpeed Attribute + // Range 0 to 65534 RPM (steps of 1 RPM) + // 65535 RPM is invalid valud - perhaps 'null' + + // Return 2000 RPM as MaxConstSpeed + return 2000; +} + +uint16_t PumpManager::GetMinConstFlow() +{ + // 1.6.10. MinConstFlow Attribute + // Range 0 m3/h to 6553.4 m3/h (steps of 0.1 m3/h) + // 6553.5 m3/h is invalid value - perhaps 'null' + + // Return 12.5 m3/h as MinConstFlow + return 125; +} + +uint16_t PumpManager::GetMaxConstFlow() +{ + // 1.6.11. MaxConstFlow Attribute + // Range 0 m3/h to 6553.4 m3/h (steps of 0.1 m3/h) + // 6553.5 m3/h is invalid value - perhaps 'null' + + // Return 655.7 m3/h as MaxConstFlow + return 6557; +} + +int16_t PumpManager::GetMinConstTemp() +{ + // 1.6.12. MinConstTemp Attribute + // Range -273.15 C to 327.67 C (steps of 0.01 C) + // All other values are invalid values - perhaps 'null' + + // Return 30.00 C as MinConstTemp + return 3000; +} + +int16_t PumpManager::GetMaxConstTemp() +{ + // 1.6.13. MaxConstTemp Attribute + // Range -273.15 C to 327.67 C (steps of 0.01 C) + // All other values are invalid values - perhaps 'null' + + // Return 56.00 C as MaxConstTemp + return 5600; +} diff --git a/examples/pump-app/nrfconnect/main/include/PumpManager.h b/examples/pump-app/nrfconnect/main/include/PumpManager.h index afc1b571e40acd..eb2f0868e1242a 100644 --- a/examples/pump-app/nrfconnect/main/include/PumpManager.h +++ b/examples/pump-app/nrfconnect/main/include/PumpManager.h @@ -51,6 +51,20 @@ class PumpManager bool IsActionInProgress(); bool InitiateAction(int32_t aActor, Action_t aAction); + int16_t GetMaxPressure(); + uint16_t GetMaxSpeed(); + uint16_t GetMaxFlow(); + int16_t GetMinConstPressure(); + int16_t GetMaxConstPressure(); + int16_t GetMinCompPressure(); + int16_t GetMaxCompPressure(); + uint16_t GetMinConstSpeed(); + uint16_t GetMaxConstSpeed(); + uint16_t GetMinConstFlow(); + uint16_t GetMaxConstFlow(); + int16_t GetMinConstTemp(); + int16_t GetMaxConstTemp(); + typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); typedef void (*Callback_fn_completed)(Action_t, int32_t aActor); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp index fe0fcf339a695f..b728e1109508d3 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -277,7 +277,7 @@ void AppTask::ActionInitiated(PumpManager::Action_t aAction, int32_t aActor) LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); } -void AppTask::ActionCompleted(PumpManager::Action_t aAction) +void AppTask::ActionCompleted(PumpManager::Action_t aAction, int32_t aActor) { // if the action has been completed by the pump, update the pump trait. // Turn on the pump state LED if in a STARTED state OR @@ -298,6 +298,10 @@ void AppTask::ActionCompleted(PumpManager::Action_t aAction) LED_stopBlinking(sAppRedHandle); LED_setOff(sAppRedHandle); } + if (aActor == AppEvent::kEventType_ButtonLeft) + { + sAppTask.UpdateClusterState(); + } } void AppTask::DispatchEvent(AppEvent * aEvent) diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/PumpManager.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/PumpManager.cpp index 6d5020f3e89f10..1f35713f20031c 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/PumpManager.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/PumpManager.cpp @@ -88,8 +88,8 @@ bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction) else if (mState == kState_StopCompleted && aAction == START_ACTION) { action_initiated = true; - - new_state = kState_StartInitiated; + mCurrentActor = aActor; + new_state = kState_StartInitiated; } if (action_initiated) @@ -188,7 +188,7 @@ void PumpManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent) { if (pump->mActionCompleted_CB) { - pump->mActionCompleted_CB(actionCompleted); + pump->mActionCompleted_CB(actionCompleted, pump->mCurrentActor); } if (pump->mAutoRestart && actionCompleted == STOP_ACTION) diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h index 65fb71df49adc9..11e402ebe3bcb9 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/AppTask.h @@ -47,7 +47,7 @@ class AppTask int Init(); static void ActionInitiated(PumpManager::Action_t aAction, int32_t aActor); - static void ActionCompleted(PumpManager::Action_t aAction); + static void ActionCompleted(PumpManager::Action_t aAction, int32_t aActor); void DispatchEvent(AppEvent * event); diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h index 62988216fec1fb..40a3961dd09161 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/PumpManager.h @@ -53,22 +53,8 @@ class PumpManager bool IsActionInProgress(); bool InitiateAction(int32_t aActor, Action_t aAction); - int16_t GetMaxPressure(); - uint16_t GetMaxSpeed(); - uint16_t GetMaxFlow(); - int16_t GetMinConstPressure(); - int16_t GetMaxConstPressure(); - int16_t GetMinCompPressure(); - int16_t GetMaxCompPressure(); - uint16_t GetMinConstSpeed(); - uint16_t GetMaxConstSpeed(); - uint16_t GetMinConstFlow(); - uint16_t GetMaxConstFlow(); - int16_t GetMinConstTemp(); - int16_t GetMaxConstTemp(); - typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); - typedef void (*Callback_fn_completed)(Action_t); + typedef void (*Callback_fn_completed)(Action_t, int32_t aActor); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); private: @@ -82,6 +68,7 @@ class PumpManager uint32_t mAutoStartDuration; bool mAutoStartTimerArmed; TimerHandle_t mTimerHandle; + int32_t mCurrentActor; void CancelTimer(void); void PumpTimer(uint32_t aTimeoutMs); diff --git a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp index 844bf837042268..dd4cd3d88a6b38 100644 --- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -503,15 +504,4 @@ void AppTask::DispatchEvent(AppEvent * aEvent) } } -void AppTask::UpdateClusterState() -{ - uint8_t newValue = !PumpMgr().IsStopped(); - - // write the new on/off value - EmberAfStatus status = emberAfWriteAttribute(1, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, &newValue, - ZCL_BOOLEAN_ATTRIBUTE_TYPE); - if (status != EMBER_ZCL_STATUS_SUCCESS) - { - LOG_ERR("Updating on/off %x", status); - } -} +void AppTask::UpdateClusterState() {} diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java index 73ba96d648c921..fe366bbf9678f8 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java @@ -5332,7 +5332,6 @@ public Map getClusterMap() { Map modeSelectClusterCommandInfoMap = new LinkedHashMap<>(); Map modeSelectchangeToModeCommandParams = new LinkedHashMap(); - // PLEASE UPDATE LATER: fill out parameter types CommandParameterInfo modeSelectchangeToModeCommandParameterInfo = new CommandParameterInfo("ModeSelect", ChipClusters.DefaultClusterCallback.class); CommandParameterInfo modeSelectchangeToModenewModeCommandParameterInfo =