Skip to content

Commit 76064d7

Browse files
Using EnergyCalendar cluster
1 parent c90a69f commit 76064d7

File tree

5 files changed

+332
-151
lines changed

5 files changed

+332
-151
lines changed

examples/all-clusters-app/all-clusters-common/src/energy-calendar-instance.h examples/all-clusters-app/all-clusters-common/include/energy-calendar-instance.h

+27-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <app/reporting/reporting.h>
2828
#include <app/util/attribute-storage.h>
2929
#include <lib/core/CHIPError.h>
30-
#include <protocols/interaction_model/StatusCode.h>
3130

3231
#include <app/clusters/energy-calendar-server/energy-calendar-server.h>
3332
#include <json/value.h>
@@ -45,33 +44,50 @@ class CalendarProviderInstance : public CalendarProvider
4544
public:
4645
CalendarProviderInstance() : CalendarProvider(1) {}
4746
CalendarProviderInstance(EndpointId ep) : CalendarProvider(ep) {}
48-
~CalendarProviderInstance() { }
47+
~CalendarProviderInstance();
4948

5049
void Init(void);
5150

5251
void SetDefault(void);
5352

5453
CHIP_ERROR LoadJson(Json::Value & root);
5554

56-
void UpdateDays(uint32_t time);
57-
void MoveToNextDay(void);
58-
void UpdatePeak(uint32_t time);
59-
void MoveToNextPeak(void);
60-
6155
/* owerride */
62-
Protocols::InteractionModel::Status GetDays(EndpointId ep, DataModel::Nullable<Structs::DayStruct::Type> &CurrentDay,
56+
CHIP_ERROR GetDays(EndpointId ep, DataModel::Nullable<Structs::DayStruct::Type> &CurrentDay,
6357
DataModel::Nullable<Structs::DayStruct::Type> &NextDay) override;
6458

6559
private:
66-
uint32_t date;
60+
uint32_t mDate;
6761
uint32_t time;
6862

63+
// Attributes contaners allocated memory
64+
DataModel::List<Structs::CalendarPeriodStruct::Type> mCalendarPeriods;
65+
DataModel::List<Structs::DayStruct::Type> mSpecialDays;
66+
Structs::DayStruct::Type mCurrentDay;
67+
Structs::DayStruct::Type mNextDay;
68+
69+
6970
DataModel::Nullable<Structs::DayStruct::Type> GetDay(uint32_t date);
70-
bool CheckPeriods(DataModel::DecodableList<Structs::CalendarPeriodStruct::Type> periods);
71-
bool CheckSpecialDays(DataModel::DecodableList<Structs::DayStruct::Type> days);
71+
bool CheckSpecialDays();
7272
bool CheckDay(const Structs::DayStruct::Type &day);
73+
bool CheckPeriods();
74+
75+
void JsonToCalendarPeriodStruct(Json::Value & root, Structs::CalendarPeriodStruct::Type &value);
76+
void JsonToDayStruct(Json::Value & root, Structs::DayStruct::Type &value);
77+
void JsonToPeakPeriodStruct(Json::Value & root, Structs::PeakPeriodStruct::Type &value);
78+
79+
void JsonToCalendarPeriodStructList(Json::Value & root, DataModel::List<Structs::CalendarPeriodStruct::Type> &value);
80+
void JsonToDayStructList(Json::Value & root, DataModel::List<Structs::DayStruct::Type> &value);
81+
void JsonToTransitionStructList(Json::Value & root, DataModel::List<Structs::TransitionStruct::Type> &value);
82+
83+
void FreeMemoryDayStruct(Structs::DayStruct::Type &value);
84+
void FreeMemoryDayStructList(DataModel::List<Structs::DayStruct::Type> &value);
85+
void FreeMemoryCalendarPeriodStruct(Structs::CalendarPeriodStruct::Type &value);
86+
void FreeMemoryCalendarPeriodStructList(DataModel::List<Structs::CalendarPeriodStruct::Type> &value);
7387
};
7488

89+
CalendarProviderInstance *GetProvider();
90+
7591
} // namespace EnergyCalendar
7692
} // namespace Clusters
7793
} // namespace app

0 commit comments

Comments
 (0)