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

[examples] Update nrfconnect pump examples #11127

Merged
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
348671b
Update pump-app and documentation removing old lock-app code.
andersbangGF Oct 14, 2021
cf7e3db
Restyled
andersbangGF Oct 14, 2021
060880b
Update pump-controller-app and documentation removing old lock-app re…
andersbangGF Oct 14, 2021
e7d9be4
Restyle changed files
andersbangGF Oct 14, 2021
3d4d803
Restyled by whitespace
restyled-commits Oct 14, 2021
8a9135b
Removed submodule added from bad merge.
andersbangGF Oct 14, 2021
d1ec921
Reverted zap repo to correct version
andersbangGF Oct 14, 2021
8194357
Corrected spelling
andersbangGF Oct 14, 2021
fe1288d
Enabled extended discovery to support multiadmin on TI platform
andersbangGF Oct 14, 2021
e19a910
Restyled by whitespace
restyled-commits Oct 14, 2021
adc2fe7
Merge branch 'master' into feature/Update_TI_Pump_Examples
andersbangGF Oct 15, 2021
2d319bc
pump-app: Replaced use of emberAfWriteServerAttribute calls with corr…
andersbangGF Oct 15, 2021
16d223f
Fixed a typo in the log output for UpdateClusterState
andersbangGF Oct 15, 2021
89c6e3b
Replaced usage of emberAf call's with correct accessors for nrfconnec…
andersbangGF Oct 15, 2021
eebb6f8
Merge branch 'feature/Update_TI_Pump_Examples' into feature/Update_nr…
andersbangGF Oct 15, 2021
2dd4a6c
Minor merge fixes. Built all pump examples (nrf + TI)
andersbangGF Oct 15, 2021
73bc6b0
Merge branch 'master' into feature/Update_nrfconnect_Pump_Examples
andersbangGF Oct 27, 2021
8cd6ec7
Merge branch 'master' into feature/Update_nrfconnect_Pump_Examples
andersbangGF Oct 27, 2021
bd5eaf3
Merge branch 'master' into feature/Update_nrfconnect_Pump_Examples
andersbangGF Oct 28, 2021
68572d3
Fixed bad merge of AppTask.cpp for TI Pump-app
andersbangGF Oct 28, 2021
b517a50
Fix bad merge of pump-manager for TI Pump App
andersbangGF Oct 28, 2021
a233b7d
One more attempt to fix bad merge.
andersbangGF Oct 28, 2021
710de22
Corrected type on maxSpeed attribute for pump-app
andersbangGF Oct 28, 2021
98fb78a
Removed On/Off cluster update from pump-controller-apps as the attrib…
andersbangGF Oct 28, 2021
d443f60
revert submodule
andersbangGF Oct 28, 2021
7eab093
Restyled by whitespace
restyled-commits Oct 28, 2021
8a9f186
Removed unused declarations from pump manager in pump-controller-app
andersbangGF Oct 29, 2021
cbb5e17
Merge branch 'master' into feature/Update_nrfconnect_Pump_Examples
andersbangGF Oct 30, 2021
79651e4
Regen ZAP
andersbangGF Oct 30, 2021
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
39 changes: 23 additions & 16 deletions examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 5 additions & 6 deletions examples/pump-app/cc13x2x7_26x2x7/main/PumpManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -113,7 +113,6 @@ bool PumpManager::InitiateAction(int32_t aActor, Action_t aAction)
mActionInitiated_CB(aAction, aActor);
}
}

return action_initiated;
}

Expand Down Expand Up @@ -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)
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 @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion examples/pump-app/cc13x2x7_26x2x7/main/include/PumpManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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);
Expand Down
112 changes: 106 additions & 6 deletions examples/pump-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app/util/attribute-storage.h>

Expand All @@ -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));

Expand All @@ -60,6 +64,7 @@ static k_timer sFunctionTimer;

using namespace ::chip::Credentials;
using namespace ::chip::DeviceLayer;
using namespace ::chip::app::Clusters;

AppTask AppTask::sAppTask;

Expand Down Expand Up @@ -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();

// 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);
status = OnOff::Attributes::OnOff::Set(ONOFF_CLUSTER_ENDPOINT, onOffState);
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
LOG_ERR("Updating on/off %x", status);
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);
}

int16_t maxConstTemp = PumpMgr().GetMaxConstTemp();
status = PumpConfigurationAndControl::Attributes::MaxConstTemp::Set(PCC_CLUSTER_ENDPOINT, maxConstTemp);
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
ChipLogError(NotSpecified, "ERR: Updating MaxConstTemp %" PRIx8, status);
}
}
Loading