Skip to content

Commit

Permalink
Create DishwasherManager.h
Browse files Browse the repository at this point in the history
  • Loading branch information
lboue authored Sep 17, 2024
1 parent 32200d1 commit aa93ff4
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions examples/dishwasher-app/linux/include/DishwasherManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
*
* Copyright (c) 2024 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.
*/

#pragma once
#include "AppEvent.h"
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/ConcreteAttributePath.h>
// https://github.com/project-chip/connectedhomeip/tree/master/src/app/clusters/dishwasher-alarm-server
#include <app/clusters/dishwasher-alarm-server/dishwasher-alarm-server.h
#include <app/util/attribute-storage.h>
#include <cmsis_os2.h>
#include <lib/core/CHIPError.h>
#include <lib/support/logging/CHIPLogging.h>
#include <stdbool.h>
#include <stdint.h>

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters::DishwasherAlarm;
using namespace chip::app::Clusters::DishwasherAlarm::Attributes;
/*
using namespace chip::app::Clusters::TemperatureControl;
using namespace chip::app::Clusters::TemperatureControl::Attributes;
using namespace chip::app::Clusters::RefrigeratorAndTemperatureControlledCabinetMode;
*/
using namespace chip::DeviceLayer;
using chip::Protocols::InteractionModel::Status;

// AppCluster Spec Table 85.
enum SUPPORTED_MODES
{
NORMAL = 0x0000,
ENERGY_SAVE = 0x0004,
RAPID_COOL = 0x4000,
RAPID_FREEZE = 0x4001,
};

class DishwasherManager
{
public:
CHIP_ERROR Init();
/*
void RefAndTempCtrlAttributeChangeHandler(EndpointId endpointId, AttributeId attributeId, uint8_t * value, uint16_t size);
void TempCtrlAttributeChangeHandler(EndpointId endpointId, AttributeId attributeId, uint8_t * value, uint16_t size);
*/
void RefAlaramAttributeChangeHandler(EndpointId endpointId, AttributeId attributeId, uint8_t * value, uint16_t size);
uint8_t GetMode();
int8_t GetCurrentTemp();
int8_t SetMode();

private:
friend DishwasherManager & DishwasherMgr();

int16_t mCurrentMode;
int16_t mStartUpMode;
int16_t mOnMode;

/*
int16_t mTemperatureSetpoint;
int16_t mMinTemperature;
int16_t mMaxTemperature;
int16_t mStep;
int16_t mSelectedTemperatureLevel;
int16_t mSupportedTemperatureLevels;
*/

chip::app::Clusters::DishwasherAlarm::AlarmBitmap mMask;
chip::app::Clusters::DishwasherAlarm::AlarmBitmap mState;
chip::app::Clusters::DishwasherAlarm::AlarmBitmap mSupported;

int8_t ConvertToPrintableTemp(int16_t temperature);
static DishwasherManager sDishwasherMgr;
};

inline DishwasherManager & DishwasherMgr()
{
return DishwasherManager::sDishwasherMgr;
}

0 comments on commit aa93ff4

Please sign in to comment.