27
27
#include < app/reporting/reporting.h>
28
28
#include < app/util/attribute-storage.h>
29
29
#include < lib/core/CHIPError.h>
30
- #include < protocols/interaction_model/StatusCode.h>
31
30
32
31
#include < app/clusters/energy-calendar-server/energy-calendar-server.h>
33
32
#include < json/value.h>
@@ -45,33 +44,50 @@ class CalendarProviderInstance : public CalendarProvider
45
44
public:
46
45
CalendarProviderInstance () : CalendarProvider(1 ) {}
47
46
CalendarProviderInstance (EndpointId ep) : CalendarProvider(ep) {}
48
- ~CalendarProviderInstance () { }
47
+ ~CalendarProviderInstance ();
49
48
50
49
void Init (void );
51
50
52
51
void SetDefault (void );
53
52
54
53
CHIP_ERROR LoadJson (Json::Value & root);
55
54
56
- void UpdateDays (uint32_t time);
57
- void MoveToNextDay (void );
58
- void UpdatePeak (uint32_t time);
59
- void MoveToNextPeak (void );
60
-
61
55
/* 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,
63
57
DataModel::Nullable<Structs::DayStruct::Type> &NextDay) override ;
64
58
65
59
private:
66
- uint32_t date ;
60
+ uint32_t mDate ;
67
61
uint32_t time;
68
62
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
+
69
70
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 ();
72
72
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);
73
87
};
74
88
89
+ CalendarProviderInstance *GetProvider ();
90
+
75
91
} // namespace EnergyCalendar
76
92
} // namespace Clusters
77
93
} // namespace app
0 commit comments