Skip to content

Commit 5e05359

Browse files
Revert type DayStruct.Date to epoch
Revert implementing Date type as struct
1 parent 9843eda commit 5e05359

File tree

24 files changed

+53
-1002
lines changed

24 files changed

+53
-1002
lines changed

src/app/codegen-data-model/tests/TestCodegenModelViaMocks.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ const MockNodeConfig gTestNodeConfig({
326326
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_VOLTAGE_MV_ATTRIBUTE_TYPE),
327327
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_ENERGY_MWH_ATTRIBUTE_TYPE),
328328
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_TOD_ATTRIBUTE_TYPE),
329+
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_DATE_ATTRIBUTE_TYPE),
329330
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_EPOCH_US_ATTRIBUTE_TYPE),
330331
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_EPOCH_S_ATTRIBUTE_TYPE),
331332
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_POSIX_MS_ATTRIBUTE_TYPE),
@@ -398,6 +399,7 @@ const MockNodeConfig gTestNodeConfig({
398399
MOCK_ATTRIBUTE_CONFIG_NULLABLE(ZCL_VOLTAGE_MV_ATTRIBUTE_TYPE),
399400
MOCK_ATTRIBUTE_CONFIG_NULLABLE(ZCL_ENERGY_MWH_ATTRIBUTE_TYPE),
400401
MOCK_ATTRIBUTE_CONFIG_NULLABLE(ZCL_TOD_ATTRIBUTE_TYPE),
402+
MOCK_ATTRIBUTE_CONFIG_NULLABLE(ZCL_DATE_ATTRIBUTE_TYPE),
401403
MOCK_ATTRIBUTE_CONFIG_NULLABLE(ZCL_EPOCH_US_ATTRIBUTE_TYPE),
402404
MOCK_ATTRIBUTE_CONFIG_NULLABLE(ZCL_EPOCH_S_ATTRIBUTE_TYPE),
403405
MOCK_ATTRIBUTE_CONFIG_NULLABLE(ZCL_POSIX_MS_ATTRIBUTE_TYPE),

src/app/zap-templates/zcl/data-model/chip/chip-types.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ limitations under the License.
6464
<type id="0xE7" description="Percentage units 0.01%" name="percent100ths" size="2" analog="true" />
6565

6666
<type id="0xE0" description="Time of day" name="tod" size="4" analog="true" />
67-
<!-- <type id="0xE1" description="Date" name="date" size="4" analog="true" /> -->
67+
<type id="0xE1" description="Date" name="date" size="4" analog="true" />
6868
<type id="0xE3" description="Epoch Microseconds" name="epoch_us" size="8" analog="true" />
6969
<type id="0xE4" description="Epoch Seconds" name="epoch_s" size="4" analog="true" />
7070
<type id="0xE5" description="Posix Time Milliseconds" name="posix_ms" size="8" analog="true" />

src/app/zap-templates/zcl/data-model/chip/energy-calendar-cluster.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ limitations under the License.
5555

5656
<struct name="DayStruct" apiMaturity="provisional">
5757
<cluster code="0x009A"/>
58-
<item fieldId="0" name="Date" type="DateStruct" optional="true"/>
58+
<item fieldId="0" name="Date" type="epoch_s" optional="true"/>
5959
<item fieldId="1" name="DaysOfWeek" type="TransitionDayOfWeekBitmap" optional="true" min="0x00" max="0x7F"/>
6060
<item fieldId="2" name="Transitions" array="true" type="TransitionStruct" length="48" minLength="1"/>
6161
<item fieldId="3" name="CalendarID" type="int32u" optional="true"/>

src/app/zap-templates/zcl/data-model/chip/global-structs.xml

-10
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,4 @@ TODO: Make these structures global rather than defining them for each cluster.
3131
<item fieldId="1" name="FloorNumber" type="int16s" isNullable="true" optional="false"/>
3232
<item fieldId="2" name="AreaType" type="AreaTypeTag" isNullable="true" optional="false"/>
3333
</struct>
34-
35-
<struct name="DateStruct">
36-
<cluster code="0x009A"/> <!-- Energy Calendar -->
37-
<cluster code="0x0B06"/> <!-- Without this scripts/tools/zap_regen_all.py pushes global DateStruct to EnergyCalendar namespace -->
38-
39-
<item fieldId="0" name="Year" type="int8u" isNullable="true" optional="false"/>
40-
<item fieldId="1" name="Month" type="int8u" min="1" max="12" isNullable="true" optional="false"/>
41-
<item fieldId="2" name="Day" type="int8u" min="1" max="31" isNullable="true" optional="false"/>
42-
<item fieldId="3" name="DayOfWeek" type="int8u" min="1" max="7" isNullable="true" optional="false"/>
43-
</struct>
4434
</configurator>

src/controller/data_model/controller-clusters.matter

+1-8
Original file line numberDiff line numberDiff line change
@@ -5113,15 +5113,8 @@ cluster EnergyCalendar = 154 {
51135113
optional AuxiliaryLoadBitmap auxiliaryLoad = 3;
51145114
}
51155115

5116-
struct DateStruct {
5117-
nullable int8u year = 0;
5118-
nullable int8u month = 1;
5119-
nullable int8u day = 2;
5120-
nullable int8u dayOfWeek = 3;
5121-
}
5122-
51235116
struct DayStruct {
5124-
optional DateStruct date = 0;
5117+
optional epoch_s date = 0;
51255118
optional TransitionDayOfWeekBitmap daysOfWeek = 1;
51265119
TransitionStruct transitions[] = 2;
51275120
optional int32u calendarID = 3;

src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java

+7-98
Original file line numberDiff line numberDiff line change
@@ -8501,99 +8501,8 @@ public String toString() {
85018501
return output.toString();
85028502
}
85038503
}
8504-
public static class EnergyCalendarClusterDateStruct {
8505-
public @Nullable Integer year;
8506-
public @Nullable Integer month;
8507-
public @Nullable Integer day;
8508-
public @Nullable Integer dayOfWeek;
8509-
private static final long YEAR_ID = 0L;
8510-
private static final long MONTH_ID = 1L;
8511-
private static final long DAY_ID = 2L;
8512-
private static final long DAY_OF_WEEK_ID = 3L;
8513-
8514-
public EnergyCalendarClusterDateStruct(
8515-
@Nullable Integer year,
8516-
@Nullable Integer month,
8517-
@Nullable Integer day,
8518-
@Nullable Integer dayOfWeek
8519-
) {
8520-
this.year = year;
8521-
this.month = month;
8522-
this.day = day;
8523-
this.dayOfWeek = dayOfWeek;
8524-
}
8525-
8526-
public StructType encodeTlv() {
8527-
ArrayList<StructElement> values = new ArrayList<>();
8528-
values.add(new StructElement(YEAR_ID, year != null ? new UIntType(year) : new NullType()));
8529-
values.add(new StructElement(MONTH_ID, month != null ? new UIntType(month) : new NullType()));
8530-
values.add(new StructElement(DAY_ID, day != null ? new UIntType(day) : new NullType()));
8531-
values.add(new StructElement(DAY_OF_WEEK_ID, dayOfWeek != null ? new UIntType(dayOfWeek) : new NullType()));
8532-
8533-
return new StructType(values);
8534-
}
8535-
8536-
public static EnergyCalendarClusterDateStruct decodeTlv(BaseTLVType tlvValue) {
8537-
if (tlvValue == null || tlvValue.type() != TLVType.Struct) {
8538-
return null;
8539-
}
8540-
@Nullable Integer year = null;
8541-
@Nullable Integer month = null;
8542-
@Nullable Integer day = null;
8543-
@Nullable Integer dayOfWeek = null;
8544-
for (StructElement element: ((StructType)tlvValue).value()) {
8545-
if (element.contextTagNum() == YEAR_ID) {
8546-
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
8547-
UIntType castingValue = element.value(UIntType.class);
8548-
year = castingValue.value(Integer.class);
8549-
}
8550-
} else if (element.contextTagNum() == MONTH_ID) {
8551-
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
8552-
UIntType castingValue = element.value(UIntType.class);
8553-
month = castingValue.value(Integer.class);
8554-
}
8555-
} else if (element.contextTagNum() == DAY_ID) {
8556-
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
8557-
UIntType castingValue = element.value(UIntType.class);
8558-
day = castingValue.value(Integer.class);
8559-
}
8560-
} else if (element.contextTagNum() == DAY_OF_WEEK_ID) {
8561-
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
8562-
UIntType castingValue = element.value(UIntType.class);
8563-
dayOfWeek = castingValue.value(Integer.class);
8564-
}
8565-
}
8566-
}
8567-
return new EnergyCalendarClusterDateStruct(
8568-
year,
8569-
month,
8570-
day,
8571-
dayOfWeek
8572-
);
8573-
}
8574-
8575-
@Override
8576-
public String toString() {
8577-
StringBuilder output = new StringBuilder();
8578-
output.append("EnergyCalendarClusterDateStruct {\n");
8579-
output.append("\tyear: ");
8580-
output.append(year);
8581-
output.append("\n");
8582-
output.append("\tmonth: ");
8583-
output.append(month);
8584-
output.append("\n");
8585-
output.append("\tday: ");
8586-
output.append(day);
8587-
output.append("\n");
8588-
output.append("\tdayOfWeek: ");
8589-
output.append(dayOfWeek);
8590-
output.append("\n");
8591-
output.append("}\n");
8592-
return output.toString();
8593-
}
8594-
}
85958504
public static class EnergyCalendarClusterDayStruct {
8596-
public Optional<ChipStructs.EnergyCalendarClusterDateStruct> date;
8505+
public Optional<Long> date;
85978506
public Optional<Integer> daysOfWeek;
85988507
public ArrayList<ChipStructs.EnergyCalendarClusterTransitionStruct> transitions;
85998508
public Optional<Long> calendarID;
@@ -8603,7 +8512,7 @@ public static class EnergyCalendarClusterDayStruct {
86038512
private static final long CALENDAR_I_D_ID = 3L;
86048513

86058514
public EnergyCalendarClusterDayStruct(
8606-
Optional<ChipStructs.EnergyCalendarClusterDateStruct> date,
8515+
Optional<Long> date,
86078516
Optional<Integer> daysOfWeek,
86088517
ArrayList<ChipStructs.EnergyCalendarClusterTransitionStruct> transitions,
86098518
Optional<Long> calendarID
@@ -8616,7 +8525,7 @@ public EnergyCalendarClusterDayStruct(
86168525

86178526
public StructType encodeTlv() {
86188527
ArrayList<StructElement> values = new ArrayList<>();
8619-
values.add(new StructElement(DATE_ID, date.<BaseTLVType>map((nonOptionaldate) -> nonOptionaldate.encodeTlv()).orElse(new EmptyType())));
8528+
values.add(new StructElement(DATE_ID, date.<BaseTLVType>map((nonOptionaldate) -> new UIntType(nonOptionaldate)).orElse(new EmptyType())));
86208529
values.add(new StructElement(DAYS_OF_WEEK_ID, daysOfWeek.<BaseTLVType>map((nonOptionaldaysOfWeek) -> new UIntType(nonOptionaldaysOfWeek)).orElse(new EmptyType())));
86218530
values.add(new StructElement(TRANSITIONS_ID, ArrayType.generateArrayType(transitions, (elementtransitions) -> elementtransitions.encodeTlv())));
86228531
values.add(new StructElement(CALENDAR_I_D_ID, calendarID.<BaseTLVType>map((nonOptionalcalendarID) -> new UIntType(nonOptionalcalendarID)).orElse(new EmptyType())));
@@ -8628,15 +8537,15 @@ public static EnergyCalendarClusterDayStruct decodeTlv(BaseTLVType tlvValue) {
86288537
if (tlvValue == null || tlvValue.type() != TLVType.Struct) {
86298538
return null;
86308539
}
8631-
Optional<ChipStructs.EnergyCalendarClusterDateStruct> date = Optional.empty();
8540+
Optional<Long> date = Optional.empty();
86328541
Optional<Integer> daysOfWeek = Optional.empty();
86338542
ArrayList<ChipStructs.EnergyCalendarClusterTransitionStruct> transitions = null;
86348543
Optional<Long> calendarID = Optional.empty();
86358544
for (StructElement element: ((StructType)tlvValue).value()) {
86368545
if (element.contextTagNum() == DATE_ID) {
8637-
if (element.value(BaseTLVType.class).type() == TLVType.Struct) {
8638-
StructType castingValue = element.value(StructType.class);
8639-
date = Optional.of(ChipStructs.EnergyCalendarClusterDateStruct.decodeTlv(castingValue));
8546+
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
8547+
UIntType castingValue = element.value(UIntType.class);
8548+
date = Optional.of(castingValue.value(Long.class));
86408549
}
86418550
} else if (element.contextTagNum() == DAYS_OF_WEEK_ID) {
86428551
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {

src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ structs_sources = [
6565
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt",
6666
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt",
6767
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterCalendarPeriodStruct.kt",
68-
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterDateStruct.kt",
6968
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterDayStruct.kt",
7069
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterPeakPeriodStruct.kt",
7170
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterTransitionStruct.kt",

src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterDateStruct.kt

-109
This file was deleted.

src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterDayStruct.kt

+3-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import matter.tlv.TlvReader
2525
import matter.tlv.TlvWriter
2626

2727
class EnergyCalendarClusterDayStruct(
28-
val date: Optional<EnergyCalendarClusterDateStruct>,
28+
val date: Optional<ULong>,
2929
val daysOfWeek: Optional<UInt>,
3030
val transitions: List<EnergyCalendarClusterTransitionStruct>,
3131
val calendarID: Optional<ULong>,
@@ -44,7 +44,7 @@ class EnergyCalendarClusterDayStruct(
4444
startStructure(tlvTag)
4545
if (date.isPresent) {
4646
val optdate = date.get()
47-
optdate.toTlv(ContextSpecificTag(TAG_DATE), this)
47+
put(ContextSpecificTag(TAG_DATE), optdate)
4848
}
4949
if (daysOfWeek.isPresent) {
5050
val optdaysOfWeek = daysOfWeek.get()
@@ -73,9 +73,7 @@ class EnergyCalendarClusterDayStruct(
7373
tlvReader.enterStructure(tlvTag)
7474
val date =
7575
if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATE))) {
76-
Optional.of(
77-
EnergyCalendarClusterDateStruct.fromTlv(ContextSpecificTag(TAG_DATE), tlvReader)
78-
)
76+
Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_DATE)))
7977
} else {
8078
Optional.empty()
8179
}

src/controller/java/generated/java/matter/controller/cluster/files.gni

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ matter_structs_sources = [
6565
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt",
6666
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt",
6767
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterCalendarPeriodStruct.kt",
68-
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterDateStruct.kt",
6968
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterDayStruct.kt",
7069
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterPeakPeriodStruct.kt",
7170
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterTransitionStruct.kt",

0 commit comments

Comments
 (0)