forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppTask.cpp
683 lines (585 loc) · 22 KB
/
AppTask.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
/*
*
* Copyright (c) 2020 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "AppTask.h"
#include "AppConfig.h"
#include "LEDWidget.h"
#include "PumpManager.h"
#include "ThreadUtil.h"
#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/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <app/util/attribute-storage.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>
#include <lib/support/CHIPMem.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/ErrorStr.h>
#include <system/SystemClock.h>
#if CONFIG_CHIP_OTA_REQUESTOR
#include <app/clusters/ota-requestor/BDXDownloader.h>
#include <app/clusters/ota-requestor/GenericOTARequestorDriver.h>
#include <app/clusters/ota-requestor/OTARequestor.h>
#include <platform/nrfconnect/OTAImageProcessorImpl.h>
#endif
#include <dk_buttons_and_leds.h>
#include <logging/log.h>
#include <zephyr.h>
using namespace ::chip;
using namespace ::chip::app::Clusters;
using namespace ::chip::Credentials;
using namespace ::chip::DeviceLayer;
#define FACTORY_RESET_TRIGGER_TIMEOUT 3000
#define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000
#define APP_EVENT_QUEUE_SIZE 10
#define BUTTON_PUSH_EVENT 1
#define BUTTON_RELEASE_EVENT 0
#define PCC_CLUSTER_ENDPOINT 1
#define ONOFF_CLUSTER_ENDPOINT 1
namespace {
LOG_MODULE_DECLARE(app);
K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), APP_EVENT_QUEUE_SIZE, alignof(AppEvent));
k_timer sFunctionTimer;
LEDWidget sStatusLED;
LEDWidget sPumpStateLED;
LEDWidget sUnusedLED;
LEDWidget sUnusedLED_1;
bool sIsThreadProvisioned = false;
bool sIsThreadEnabled = false;
bool sHaveBLEConnections = false;
#if CONFIG_CHIP_OTA_REQUESTOR
GenericOTARequestorDriver sOTARequestorDriver;
OTAImageProcessorImpl sOTAImageProcessor;
chip::BDXDownloader sBDXDownloader;
chip::OTARequestor sOTARequestor;
#endif
} // namespace
AppTask AppTask::sAppTask;
CHIP_ERROR AppTask::Init()
{
// Initialize CHIP stack
LOG_INF("Init CHIP stack");
CHIP_ERROR err = chip::Platform::MemoryInit();
if (err != CHIP_NO_ERROR)
{
LOG_ERR("Platform::MemoryInit() failed");
return err;
}
err = PlatformMgr().InitChipStack();
if (err != CHIP_NO_ERROR)
{
LOG_ERR("PlatformMgr().InitChipStack() failed");
return err;
}
err = ThreadStackMgr().InitThreadStack();
if (err != CHIP_NO_ERROR)
{
LOG_ERR("ThreadStackMgr().InitThreadStack() failed");
return err;
}
err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice);
if (err != CHIP_NO_ERROR)
{
LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed");
return err;
}
// Initialize LEDs
LEDWidget::InitGpio();
LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler);
sStatusLED.Init(SYSTEM_STATE_LED);
sPumpStateLED.Init(PUMP_STATE_LED);
sPumpStateLED.Set(!PumpMgr().IsStopped());
sUnusedLED.Init(DK_LED3);
sUnusedLED_1.Init(DK_LED4);
UpdateStatusLED();
PumpMgr().Init();
PumpMgr().SetCallbacks(ActionInitiated, ActionCompleted);
// Initialize buttons
int ret = dk_buttons_init(ButtonEventHandler);
if (ret)
{
LOG_ERR("dk_buttons_init() failed");
return chip::System::MapErrorZephyr(ret);
}
// Initialize function button timer
k_timer_init(&sFunctionTimer, &AppTask::TimerEventHandler, nullptr);
k_timer_user_data_set(&sFunctionTimer, this);
#ifdef CONFIG_MCUMGR_SMP_BT
// Initialize DFU over SMP
GetDFUOverSMP().Init(RequestSMPAdvertisingStart);
GetDFUOverSMP().ConfirmNewImage();
#endif
// Initialize CHIP server
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
InitOTARequestor();
ReturnErrorOnFailure(chip::Server::GetInstance().Init());
ConfigurationMgr().LogDeviceConfig();
PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE));
// Add CHIP event handler and start CHIP thread.
// Note that all the initialization code should happen prior to this point to avoid data races
// between the main and the CHIP threads.
PlatformMgr().AddEventHandler(ChipEventHandler, 0);
err = PlatformMgr().StartEventLoopTask();
if (err != CHIP_NO_ERROR)
{
LOG_ERR("PlatformMgr().StartEventLoopTask() failed");
}
return err;
}
void AppTask::InitOTARequestor()
{
#if CONFIG_CHIP_OTA_REQUESTOR
sOTAImageProcessor.SetOTADownloader(&sBDXDownloader);
sBDXDownloader.SetImageProcessorDelegate(&sOTAImageProcessor);
sOTARequestorDriver.Init(&sOTARequestor, &sOTAImageProcessor);
sOTARequestor.Init(&chip::Server::GetInstance(), &sOTARequestorDriver, &sBDXDownloader);
chip::SetRequestorInstance(&sOTARequestor);
#endif
}
CHIP_ERROR AppTask::StartApp()
{
ReturnErrorOnFailure(Init());
AppEvent event = {};
while (true)
{
k_msgq_get(&sAppEventQueue, &event, K_FOREVER);
DispatchEvent(&event);
}
return CHIP_NO_ERROR;
}
void AppTask::StartActionEventHandler(AppEvent * aEvent)
{
PumpManager::Action_t action = PumpManager::INVALID_ACTION;
int32_t actor = 0;
if (aEvent->Type == AppEvent::kEventType_Start)
{
action = static_cast<PumpManager::Action_t>(aEvent->StartEvent.Action);
actor = aEvent->StartEvent.Actor;
}
else if (aEvent->Type == AppEvent::kEventType_Button)
{
action = PumpMgr().IsStopped() ? PumpManager::START_ACTION : PumpManager::STOP_ACTION;
actor = AppEvent::kEventType_Button;
}
if (action != PumpManager::INVALID_ACTION && !PumpMgr().InitiateAction(actor, action))
LOG_INF("Action is already in progress or active.");
}
void AppTask::ButtonEventHandler(uint32_t button_state, uint32_t has_changed)
{
AppEvent button_event;
button_event.Type = AppEvent::kEventType_Button;
if (START_BUTTON_MASK & button_state & has_changed)
{
button_event.ButtonEvent.PinNo = START_BUTTON;
button_event.ButtonEvent.Action = BUTTON_PUSH_EVENT;
button_event.Handler = StartActionEventHandler;
sAppTask.PostEvent(&button_event);
}
if (FUNCTION_BUTTON_MASK & has_changed)
{
button_event.ButtonEvent.PinNo = FUNCTION_BUTTON;
button_event.ButtonEvent.Action = (FUNCTION_BUTTON_MASK & button_state) ? BUTTON_PUSH_EVENT : BUTTON_RELEASE_EVENT;
button_event.Handler = FunctionHandler;
sAppTask.PostEvent(&button_event);
}
if (THREAD_START_BUTTON_MASK & button_state & has_changed)
{
button_event.ButtonEvent.PinNo = THREAD_START_BUTTON;
button_event.ButtonEvent.Action = BUTTON_PUSH_EVENT;
button_event.Handler = StartThreadHandler;
sAppTask.PostEvent(&button_event);
}
if (BLE_ADVERTISEMENT_START_BUTTON_MASK & button_state & has_changed)
{
button_event.ButtonEvent.PinNo = BLE_ADVERTISEMENT_START_BUTTON;
button_event.ButtonEvent.Action = BUTTON_PUSH_EVENT;
button_event.Handler = StartBLEAdvertisementHandler;
sAppTask.PostEvent(&button_event);
}
}
void AppTask::TimerEventHandler(k_timer * timer)
{
AppEvent event;
event.Type = AppEvent::kEventType_Timer;
event.TimerEvent.Context = k_timer_user_data_get(timer);
event.Handler = FunctionTimerEventHandler;
sAppTask.PostEvent(&event);
}
void AppTask::FunctionTimerEventHandler(AppEvent * aEvent)
{
if (aEvent->Type != AppEvent::kEventType_Timer)
return;
// If we reached here, the button was held past FACTORY_RESET_TRIGGER_TIMEOUT, initiate factory reset
if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_SoftwareUpdate)
{
LOG_INF("Factory Reset Triggered. Release button within %ums to cancel.", FACTORY_RESET_TRIGGER_TIMEOUT);
// Start timer for FACTORY_RESET_CANCEL_WINDOW_TIMEOUT to allow user to cancel, if required.
sAppTask.StartTimer(FACTORY_RESET_CANCEL_WINDOW_TIMEOUT);
sAppTask.mFunction = kFunction_FactoryReset;
// Turn off all LEDs before starting blink to make sure blink is co-ordinated.
sStatusLED.Set(false);
sPumpStateLED.Set(false);
sUnusedLED_1.Set(false);
sUnusedLED.Set(false);
sStatusLED.Blink(500);
sPumpStateLED.Blink(500);
sUnusedLED.Blink(500);
sUnusedLED_1.Blink(500);
}
else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_FactoryReset)
{
// Actually trigger Factory Reset
sAppTask.mFunction = kFunction_NoneSelected;
chip::Server::GetInstance().ScheduleFactoryReset();
}
}
#ifdef CONFIG_MCUMGR_SMP_BT
void AppTask::RequestSMPAdvertisingStart(void)
{
AppEvent event;
event.Type = AppEvent::kEventType_StartSMPAdvertising;
event.Handler = [](AppEvent *) { GetDFUOverSMP().StartBLEAdvertising(); };
sAppTask.PostEvent(&event);
}
#endif
void AppTask::FunctionHandler(AppEvent * aEvent)
{
if (aEvent->ButtonEvent.PinNo != FUNCTION_BUTTON)
return;
// To trigger software update: press the FUNCTION_BUTTON button briefly (< FACTORY_RESET_TRIGGER_TIMEOUT)
// To initiate factory reset: press the FUNCTION_BUTTON for FACTORY_RESET_TRIGGER_TIMEOUT + FACTORY_RESET_CANCEL_WINDOW_TIMEOUT
// All LEDs start blinking after FACTORY_RESET_TRIGGER_TIMEOUT to signal factory reset has been initiated.
// To cancel factory reset: release the FUNCTION_BUTTON once all LEDs start blinking within the
// FACTORY_RESET_CANCEL_WINDOW_TIMEOUT
if (aEvent->ButtonEvent.Action == BUTTON_PUSH_EVENT)
{
if (!sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_NoneSelected)
{
sAppTask.StartTimer(FACTORY_RESET_TRIGGER_TIMEOUT);
sAppTask.mFunction = kFunction_SoftwareUpdate;
}
}
else
{
// If the button was released before factory reset got initiated, trigger a software update.
if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_SoftwareUpdate)
{
sAppTask.CancelTimer();
sAppTask.mFunction = kFunction_NoneSelected;
#ifdef CONFIG_MCUMGR_SMP_BT
GetDFUOverSMP().StartServer();
#else
LOG_INF("Software update is disabled");
#endif
}
else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_FactoryReset)
{
sUnusedLED.Set(false);
sUnusedLED_1.Set(false);
// Set pump state LED back to show state of pump.
sPumpStateLED.Set(!PumpMgr().IsStopped());
UpdateStatusLED();
sAppTask.CancelTimer();
// Change the function to none selected since factory reset has been canceled.
sAppTask.mFunction = kFunction_NoneSelected;
LOG_INF("Factory Reset has been Canceled");
}
}
}
void AppTask::StartThreadHandler(AppEvent * aEvent)
{
if (aEvent->ButtonEvent.PinNo != THREAD_START_BUTTON)
return;
if (chip::Server::GetInstance().AddTestCommissioning() != CHIP_NO_ERROR)
{
LOG_ERR("Failed to add test pairing");
}
if (!ConnectivityMgr().IsThreadProvisioned())
{
StartDefaultThreadNetwork();
LOG_INF("Device is not commissioned to a Thread network. Starting with the default configuration.");
}
else
{
LOG_INF("Device is commissioned to a Thread network.");
}
}
void AppTask::StartBLEAdvertisementHandler(AppEvent * aEvent)
{
if (aEvent->ButtonEvent.PinNo != BLE_ADVERTISEMENT_START_BUTTON)
return;
// Don't allow on starting Matter service BLE advertising after Thread provisioning.
if (ConnectivityMgr().IsThreadProvisioned())
{
LOG_INF("NFC Tag emulation and Matter service BLE advertising not started - device is commissioned to a Thread network.");
return;
}
if (ConnectivityMgr().IsBLEAdvertisingEnabled())
{
LOG_INF("BLE advertising is already enabled");
return;
}
if (chip::Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() != CHIP_NO_ERROR)
{
LOG_ERR("OpenBasicCommissioningWindow() failed");
}
}
void AppTask::UpdateLedStateEventHandler(AppEvent * aEvent)
{
if (aEvent->Type == AppEvent::kEventType_UpdateLedState)
{
aEvent->UpdateLedStateEvent.LedWidget->UpdateState();
}
}
void AppTask::LEDStateUpdateHandler(LEDWidget & ledWidget)
{
AppEvent event;
event.Type = AppEvent::kEventType_UpdateLedState;
event.Handler = UpdateLedStateEventHandler;
event.UpdateLedStateEvent.LedWidget = &ledWidget;
sAppTask.PostEvent(&event);
}
void AppTask::UpdateStatusLED()
{
/* Update the status LED.
*
* If thread and service provisioned, keep the LED On constantly.
*
* If the system has ble connection(s) uptill the stage above, THEN blink the LED at an even
* rate of 100ms.
*
* Otherwise, blink the LED On for a very short time. */
if (sIsThreadProvisioned && sIsThreadEnabled)
{
sStatusLED.Set(true);
}
else if (sHaveBLEConnections)
{
sStatusLED.Blink(100, 100);
}
else
{
sStatusLED.Blink(50, 950);
}
}
void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* arg */)
{
switch (event->Type)
{
case DeviceEventType::kCHIPoBLEAdvertisingChange:
if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Stopped)
{
#ifdef CONFIG_CHIP_NFC_COMMISSIONING
NFCMgr().StopTagEmulation();
#endif
#ifdef CONFIG_MCUMGR_SMP_BT
// After CHIPoBLE advertising stop, start advertising SMP in case Thread is enabled or there are no active CHIPoBLE
// connections (exclude the case when CHIPoBLE advertising is stopped on the connection time)
if (GetDFUOverSMP().IsEnabled() &&
(ConnectivityMgr().IsThreadProvisioned() || ConnectivityMgr().NumBLEConnections() == 0))
sAppTask.RequestSMPAdvertisingStart();
#endif
}
#ifdef CONFIG_CHIP_NFC_COMMISSIONING
else if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Started)
{
if (NFCMgr().IsTagEmulationStarted())
{
LOG_INF("NFC Tag emulation is already started");
}
else
{
ShareQRCodeOverNFC(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE));
}
}
#endif
sHaveBLEConnections = ConnectivityMgr().NumBLEConnections() != 0;
UpdateStatusLED();
break;
case DeviceEventType::kThreadStateChange:
sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned();
sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled();
UpdateStatusLED();
break;
default:
break;
}
}
void AppTask::CancelTimer()
{
k_timer_stop(&sFunctionTimer);
mFunctionTimerActive = false;
}
void AppTask::StartTimer(uint32_t aTimeoutInMs)
{
k_timer_start(&sFunctionTimer, K_MSEC(aTimeoutInMs), K_NO_WAIT);
mFunctionTimerActive = true;
}
void AppTask::ActionInitiated(PumpManager::Action_t aAction, int32_t aActor)
{
// If the action has been initiated by the pump, update the pump trait
// and start flashing the LEDs rapidly to indicate action initiation.
if (aAction == PumpManager::START_ACTION)
{
LOG_INF("Pump Start Action has been initiated");
}
else if (aAction == PumpManager::STOP_ACTION)
{
LOG_INF("Pump Stop Action has been initiated");
}
sPumpStateLED.Blink(50, 50);
}
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
// Turn off the pump state LED if in a STOPPED state.
if (aAction == PumpManager::START_ACTION)
{
LOG_INF("Pump Start Action has been completed");
sPumpStateLED.Set(true);
}
else if (aAction == PumpManager::STOP_ACTION)
{
LOG_INF("Pump Stop Action has been completed");
sPumpStateLED.Set(false);
}
if (aActor == AppEvent::kEventType_Button)
{
sAppTask.UpdateClusterState();
}
}
void AppTask::PostStartActionRequest(int32_t aActor, PumpManager::Action_t aAction)
{
AppEvent event;
event.Type = AppEvent::kEventType_Start;
event.StartEvent.Actor = aActor;
event.StartEvent.Action = aAction;
event.Handler = StartActionEventHandler;
PostEvent(&event);
}
void AppTask::PostEvent(AppEvent * aEvent)
{
if (k_msgq_put(&sAppEventQueue, aEvent, K_NO_WAIT))
{
LOG_INF("Failed to post event to app task event queue");
}
}
void AppTask::DispatchEvent(AppEvent * aEvent)
{
if (aEvent->Handler)
{
aEvent->Handler(aEvent);
}
else
{
LOG_INF("Event received with no handler. Dropping event.");
}
}
void AppTask::UpdateClusterState()
{
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 %x", 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 %x", 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 %x", 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 %x", 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 %x", 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 %x", 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 %x", 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 %x", 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 %x", 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 %x", 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 %x", 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 %x", 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 %x", 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 %x", status);
}
}