Skip to content

Commit 90684bd

Browse files
committed
Refactor Zigbee event mapping CDDL to use separate types for each event kind
Split the zigbee-event-map union into three distinct types (zigbee-attribute-reporting, zigbee-write-event, zigbee-connection-event) instead of using a discriminated union with a type field. Update draft to clarify which fields apply to which event types.
1 parent 0646672 commit 90684bd

4 files changed

Lines changed: 97 additions & 16 deletions

File tree

cddl/zigbee-event-map.cddl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ $$SDF-EVENT-PROTOCOL-MAP //= (
22
zigbee: zigbee-event-map
33
)
44

5-
zigbee-event-type = "attribute_reporting" / "write_event"
5+
zigbee-event-map = zigbee-attribute-reporting / zigbee-write-event / zigbee-connection-event
66

7-
zigbee-event-map = {
8-
type: zigbee-event-type,
7+
zigbee-attribute-reporting = {
8+
type: "attribute_reporting",
99
endpointID: uint,
1010
clusterID: uint,
1111
attributeID: uint,
@@ -15,4 +15,18 @@ zigbee-event-map = {
1515
? minReportingInterval: uint,
1616
? maxReportingInterval: uint,
1717
? reportableChange: number,
18-
} / { type: "connection_events" }
18+
}
19+
20+
zigbee-write-event = {
21+
type: "write_event",
22+
endpointID: uint,
23+
clusterID: uint,
24+
attributeID: uint,
25+
attributeType: uint,
26+
? profileID: uint,
27+
? manufacturerCode: uint,
28+
}
29+
30+
zigbee-connection-event = {
31+
type: "connection_events",
32+
}

draft-ietf-asdf-sdf-protocol-mapping.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,19 +556,28 @@ Where:
556556
- `"connection_events"`: the event is triggered when a Zigbee end device
557557
joins or leaves the Zigbee network.
558558
- `endpointID` is the Zigbee endpoint ID that corresponds to the SDF event.
559+
It is required when `type` is `"attribute_reporting"` or `"write_event"`.
559560
- `clusterID` is the Zigbee cluster ID that corresponds to the SDF event.
561+
It is required when `type` is `"attribute_reporting"` or `"write_event"`.
560562
- `attributeID` is the Zigbee attribute ID that corresponds to the SDF event.
561-
- `attributeType` is the Zigbee data type of the attribute.
562-
- `profileID` is the Zigbee application profile ID (optional). If not provided, it defaults to the Home Automation profile (0x0104), which is the default profile in Zigbee 3.0.
563-
- `manufacturerCode` is the Zigbee manufacturer code of the attribute (optional).
563+
It is required when `type` is `"attribute_reporting"` or `"write_event"`.
564+
- `attributeType` is the Zigbee data type of the attribute. It is required
565+
when `type` is `"attribute_reporting"` or `"write_event"`.
566+
- `profileID` is the Zigbee application profile ID (optional). It only
567+
applies when `type` is `"attribute_reporting"` or `"write_event"`. If not
568+
provided, it defaults to the Home Automation profile (0x0104), which is the
569+
default profile in Zigbee 3.0.
570+
- `manufacturerCode` is the Zigbee manufacturer code of the attribute
571+
(optional). It only applies when `type` is `"attribute_reporting"` or
572+
`"write_event"`.
564573
- `minReportingInterval` is the minimum reporting interval in seconds
565574
(optional). It is the minimum time between issued attribute reports and
566-
applies only when `type` is `"attribute_reporting"`.
575+
only applies when `type` is `"attribute_reporting"`.
567576
- `maxReportingInterval` is the maximum reporting interval in seconds
568577
(optional). It is the maximum time between issued attribute reports and
569-
applies only when `type` is `"attribute_reporting"`.
578+
only applies when `type` is `"attribute_reporting"`.
570579
- `reportableChange` is the minimum change to the attribute value that triggers
571-
a report (optional). It applies only when `type` is `"attribute_reporting"`
580+
a report (optional). It only applies when `type` is `"attribute_reporting"`
572581
and to attributes with an 'analog' data type, and MUST have the same data type
573582
as the reported attribute.
574583

generated/combined.cddl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ $$SDF-EVENT-PROTOCOL-MAP //= (
6060
zigbee: zigbee-event-map
6161
)
6262

63-
zigbee-event-type = "attribute_reporting" / "write_event"
63+
zigbee-event-map = zigbee-attribute-reporting / zigbee-write-event / zigbee-connection-event
6464

65-
zigbee-event-map = {
66-
type: zigbee-event-type,
65+
zigbee-attribute-reporting = {
66+
type: "attribute_reporting",
6767
endpointID: uint,
6868
clusterID: uint,
6969
attributeID: uint,
@@ -73,7 +73,21 @@ zigbee-event-map = {
7373
? minReportingInterval: uint,
7474
? maxReportingInterval: uint,
7575
? reportableChange: number,
76-
} / { type: "connection_events" }
76+
}
77+
78+
zigbee-write-event = {
79+
type: "write_event",
80+
endpointID: uint,
81+
clusterID: uint,
82+
attributeID: uint,
83+
attributeType: uint,
84+
? profileID: uint,
85+
? manufacturerCode: uint,
86+
}
87+
88+
zigbee-connection-event = {
89+
type: "connection_events",
90+
}
7791

7892
$$SDF-ACTION-PROTOCOL-MAP //= (
7993
zigbee: zigbee-action-map

openapi/ProtocolMap-Zigbee.yaml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,16 @@ components:
5555
oneOf:
5656
- type: object
5757
required:
58+
- type
5859
- endpointID
5960
- clusterID
6061
- attributeID
6162
properties:
63+
type:
64+
type: string
65+
example: attribute_reporting
66+
enum:
67+
- attribute_reporting
6268
endpointID:
6369
type: integer
6470
format: int32
@@ -71,14 +77,17 @@ components:
7177
type: integer
7278
format: int32
7379
example: 16
74-
type:
80+
attributeType:
7581
type: integer
7682
format: int32
77-
example: 1
83+
example: 41
7884
profileID:
7985
type: integer
8086
format: int32
8187
example: 260
88+
manufacturerCode:
89+
type: integer
90+
format: int32
8291
minReportingInterval:
8392
type: integer
8493
format: int32
@@ -90,6 +99,41 @@ components:
9099
reportableChange:
91100
type: number
92101
example: 50
102+
- type: object
103+
required:
104+
- type
105+
- endpointID
106+
- clusterID
107+
- attributeID
108+
properties:
109+
type:
110+
type: string
111+
example: write_event
112+
enum:
113+
- write_event
114+
endpointID:
115+
type: integer
116+
format: int32
117+
example: 1
118+
clusterID:
119+
type: integer
120+
format: int32
121+
example: 6
122+
attributeID:
123+
type: integer
124+
format: int32
125+
example: 16
126+
attributeType:
127+
type: integer
128+
format: int32
129+
example: 41
130+
profileID:
131+
type: integer
132+
format: int32
133+
example: 260
134+
manufacturerCode:
135+
type: integer
136+
format: int32
93137
- type: object
94138
required:
95139
- type

0 commit comments

Comments
 (0)