Skip to content

Commit 62e862d

Browse files
Revert type DayStruct.Date to epoch
Revert implementing Date type as struct
1 parent 14c5a5e commit 62e862d

File tree

18 files changed

+53
-824
lines changed

18 files changed

+53
-824
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ const MockNodeConfig gTestNodeConfig({
329329
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_VOLTAGE_MV_ATTRIBUTE_TYPE),
330330
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_ENERGY_MWH_ATTRIBUTE_TYPE),
331331
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_TOD_ATTRIBUTE_TYPE),
332+
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_DATE_ATTRIBUTE_TYPE),
332333
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_EPOCH_US_ATTRIBUTE_TYPE),
333334
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_EPOCH_S_ATTRIBUTE_TYPE),
334335
MOCK_ATTRIBUTE_CONFIG_NON_NULLABLE(ZCL_POSIX_MS_ATTRIBUTE_TYPE),
@@ -401,6 +402,7 @@ const MockNodeConfig gTestNodeConfig({
401402
MOCK_ATTRIBUTE_CONFIG_NULLABLE(ZCL_VOLTAGE_MV_ATTRIBUTE_TYPE),
402403
MOCK_ATTRIBUTE_CONFIG_NULLABLE(ZCL_ENERGY_MWH_ATTRIBUTE_TYPE),
403404
MOCK_ATTRIBUTE_CONFIG_NULLABLE(ZCL_TOD_ATTRIBUTE_TYPE),
405+
MOCK_ATTRIBUTE_CONFIG_NULLABLE(ZCL_DATE_ATTRIBUTE_TYPE),
404406
MOCK_ATTRIBUTE_CONFIG_NULLABLE(ZCL_EPOCH_US_ATTRIBUTE_TYPE),
405407
MOCK_ATTRIBUTE_CONFIG_NULLABLE(ZCL_EPOCH_S_ATTRIBUTE_TYPE),
406408
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/controller/data_model/controller-clusters.matter

+1-8
Original file line numberDiff line numberDiff line change
@@ -5518,15 +5518,8 @@ cluster EnergyCalendar = 154 {
55185518
optional AuxiliaryLoadBitmap auxiliaryLoad = 3;
55195519
}
55205520

5521-
struct DateStruct {
5522-
nullable int8u year = 0;
5523-
nullable int8u month = 1;
5524-
nullable int8u day = 2;
5525-
nullable int8u dayOfWeek = 3;
5526-
}
5527-
55285521
struct DayStruct {
5529-
optional DateStruct date = 0;
5522+
optional epoch_s date = 0;
55305523
optional TransitionDayOfWeekBitmap daysOfWeek = 1;
55315524
TransitionStruct transitions[] = 2;
55325525
optional int32u calendarID = 3;

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

+7-98
Original file line numberDiff line numberDiff line change
@@ -8850,99 +8850,8 @@ public String toString() {
88508850
return output.toString();
88518851
}
88528852
}
8853-
public static class EnergyCalendarClusterDateStruct {
8854-
public @Nullable Integer year;
8855-
public @Nullable Integer month;
8856-
public @Nullable Integer day;
8857-
public @Nullable Integer dayOfWeek;
8858-
private static final long YEAR_ID = 0L;
8859-
private static final long MONTH_ID = 1L;
8860-
private static final long DAY_ID = 2L;
8861-
private static final long DAY_OF_WEEK_ID = 3L;
8862-
8863-
public EnergyCalendarClusterDateStruct(
8864-
@Nullable Integer year,
8865-
@Nullable Integer month,
8866-
@Nullable Integer day,
8867-
@Nullable Integer dayOfWeek
8868-
) {
8869-
this.year = year;
8870-
this.month = month;
8871-
this.day = day;
8872-
this.dayOfWeek = dayOfWeek;
8873-
}
8874-
8875-
public StructType encodeTlv() {
8876-
ArrayList<StructElement> values = new ArrayList<>();
8877-
values.add(new StructElement(YEAR_ID, year != null ? new UIntType(year) : new NullType()));
8878-
values.add(new StructElement(MONTH_ID, month != null ? new UIntType(month) : new NullType()));
8879-
values.add(new StructElement(DAY_ID, day != null ? new UIntType(day) : new NullType()));
8880-
values.add(new StructElement(DAY_OF_WEEK_ID, dayOfWeek != null ? new UIntType(dayOfWeek) : new NullType()));
8881-
8882-
return new StructType(values);
8883-
}
8884-
8885-
public static EnergyCalendarClusterDateStruct decodeTlv(BaseTLVType tlvValue) {
8886-
if (tlvValue == null || tlvValue.type() != TLVType.Struct) {
8887-
return null;
8888-
}
8889-
@Nullable Integer year = null;
8890-
@Nullable Integer month = null;
8891-
@Nullable Integer day = null;
8892-
@Nullable Integer dayOfWeek = null;
8893-
for (StructElement element: ((StructType)tlvValue).value()) {
8894-
if (element.contextTagNum() == YEAR_ID) {
8895-
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
8896-
UIntType castingValue = element.value(UIntType.class);
8897-
year = castingValue.value(Integer.class);
8898-
}
8899-
} else if (element.contextTagNum() == MONTH_ID) {
8900-
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
8901-
UIntType castingValue = element.value(UIntType.class);
8902-
month = castingValue.value(Integer.class);
8903-
}
8904-
} else if (element.contextTagNum() == DAY_ID) {
8905-
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
8906-
UIntType castingValue = element.value(UIntType.class);
8907-
day = castingValue.value(Integer.class);
8908-
}
8909-
} else if (element.contextTagNum() == DAY_OF_WEEK_ID) {
8910-
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
8911-
UIntType castingValue = element.value(UIntType.class);
8912-
dayOfWeek = castingValue.value(Integer.class);
8913-
}
8914-
}
8915-
}
8916-
return new EnergyCalendarClusterDateStruct(
8917-
year,
8918-
month,
8919-
day,
8920-
dayOfWeek
8921-
);
8922-
}
8923-
8924-
@Override
8925-
public String toString() {
8926-
StringBuilder output = new StringBuilder();
8927-
output.append("EnergyCalendarClusterDateStruct {\n");
8928-
output.append("\tyear: ");
8929-
output.append(year);
8930-
output.append("\n");
8931-
output.append("\tmonth: ");
8932-
output.append(month);
8933-
output.append("\n");
8934-
output.append("\tday: ");
8935-
output.append(day);
8936-
output.append("\n");
8937-
output.append("\tdayOfWeek: ");
8938-
output.append(dayOfWeek);
8939-
output.append("\n");
8940-
output.append("}\n");
8941-
return output.toString();
8942-
}
8943-
}
89448853
public static class EnergyCalendarClusterDayStruct {
8945-
public Optional<ChipStructs.EnergyCalendarClusterDateStruct> date;
8854+
public Optional<Long> date;
89468855
public Optional<Integer> daysOfWeek;
89478856
public ArrayList<ChipStructs.EnergyCalendarClusterTransitionStruct> transitions;
89488857
public Optional<Long> calendarID;
@@ -8952,7 +8861,7 @@ public static class EnergyCalendarClusterDayStruct {
89528861
private static final long CALENDAR_I_D_ID = 3L;
89538862

89548863
public EnergyCalendarClusterDayStruct(
8955-
Optional<ChipStructs.EnergyCalendarClusterDateStruct> date,
8864+
Optional<Long> date,
89568865
Optional<Integer> daysOfWeek,
89578866
ArrayList<ChipStructs.EnergyCalendarClusterTransitionStruct> transitions,
89588867
Optional<Long> calendarID
@@ -8965,7 +8874,7 @@ public EnergyCalendarClusterDayStruct(
89658874

89668875
public StructType encodeTlv() {
89678876
ArrayList<StructElement> values = new ArrayList<>();
8968-
values.add(new StructElement(DATE_ID, date.<BaseTLVType>map((nonOptionaldate) -> nonOptionaldate.encodeTlv()).orElse(new EmptyType())));
8877+
values.add(new StructElement(DATE_ID, date.<BaseTLVType>map((nonOptionaldate) -> new UIntType(nonOptionaldate)).orElse(new EmptyType())));
89698878
values.add(new StructElement(DAYS_OF_WEEK_ID, daysOfWeek.<BaseTLVType>map((nonOptionaldaysOfWeek) -> new UIntType(nonOptionaldaysOfWeek)).orElse(new EmptyType())));
89708879
values.add(new StructElement(TRANSITIONS_ID, ArrayType.generateArrayType(transitions, (elementtransitions) -> elementtransitions.encodeTlv())));
89718880
values.add(new StructElement(CALENDAR_I_D_ID, calendarID.<BaseTLVType>map((nonOptionalcalendarID) -> new UIntType(nonOptionalcalendarID)).orElse(new EmptyType())));
@@ -8977,15 +8886,15 @@ public static EnergyCalendarClusterDayStruct decodeTlv(BaseTLVType tlvValue) {
89778886
if (tlvValue == null || tlvValue.type() != TLVType.Struct) {
89788887
return null;
89798888
}
8980-
Optional<ChipStructs.EnergyCalendarClusterDateStruct> date = Optional.empty();
8889+
Optional<Long> date = Optional.empty();
89818890
Optional<Integer> daysOfWeek = Optional.empty();
89828891
ArrayList<ChipStructs.EnergyCalendarClusterTransitionStruct> transitions = null;
89838892
Optional<Long> calendarID = Optional.empty();
89848893
for (StructElement element: ((StructType)tlvValue).value()) {
89858894
if (element.contextTagNum() == DATE_ID) {
8986-
if (element.value(BaseTLVType.class).type() == TLVType.Struct) {
8987-
StructType castingValue = element.value(StructType.class);
8988-
date = Optional.of(ChipStructs.EnergyCalendarClusterDateStruct.decodeTlv(castingValue));
8895+
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
8896+
UIntType castingValue = element.value(UIntType.class);
8897+
date = Optional.of(castingValue.value(Long.class));
89898898
}
89908899
} else if (element.contextTagNum() == DAYS_OF_WEEK_ID) {
89918900
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
@@ -72,7 +72,6 @@ structs_sources = [
7272
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt",
7373
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt",
7474
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterCalendarPeriodStruct.kt",
75-
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterDateStruct.kt",
7675
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterDayStruct.kt",
7776
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyCalendarClusterPeakPeriodStruct.kt",
7877
"${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
@@ -72,7 +72,6 @@ matter_structs_sources = [
7272
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementAccuracyStruct.kt",
7373
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalPowerMeasurementClusterMeasurementRangeStruct.kt",
7474
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterCalendarPeriodStruct.kt",
75-
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterDateStruct.kt",
7675
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterDayStruct.kt",
7776
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterPeakPeriodStruct.kt",
7877
"${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyCalendarClusterTransitionStruct.kt",

0 commit comments

Comments
 (0)