Skip to content

Commit

Permalink
Map epoch_us to uint64_t and epoch_s to uint32_t (#9848)
Browse files Browse the repository at this point in the history
* Map epoch_us to uint64_t and epoch_s to uint32_t

* Update generated code
  • Loading branch information
vivien-apple authored Sep 22, 2021
1 parent e22c2bb commit e9ec676
Show file tree
Hide file tree
Showing 22 changed files with 1,568 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14017,6 +14017,36 @@
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "epoch_us",
"code": 32,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "epoch_s",
"code": 33,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
Expand Down Expand Up @@ -17539,4 +17569,4 @@
}
],
"log": []
}
}
64 changes: 64 additions & 0 deletions src/app/tests/suites/TestCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,70 @@ tests:
{ fabricIndex: 3, operationalCert: "Test3" },
]

# Tests for Epoch Microseconds

- label: "Read attribute EPOCH_US Default Value"
command: "readAttribute"
attribute: "epoch_us"
response:
value: 0

- label: "Write attribute EPOCH_US Max Value"
command: "writeAttribute"
attribute: "epoch_us"
arguments:
value: "18446744073709551615"

- label: "Read attribute EPOCH_US Max Value"
command: "readAttribute"
attribute: "epoch_us"
response:
value: "18446744073709551615"

- label: "Write attribute EPOCH_US Min Value"
command: "writeAttribute"
attribute: "epoch_us"
arguments:
value: 0

- label: "Read attribute EPOCH_US Min Value"
command: "readAttribute"
attribute: "epoch_us"
response:
value: 0

# Tests for Epoch Seconds

- label: "Read attribute EPOCH_S Default Value"
command: "readAttribute"
attribute: "epoch_s"
response:
value: 0

- label: "Write attribute EPOCH_S Max Value"
command: "writeAttribute"
attribute: "epoch_s"
arguments:
value: 4294967295

- label: "Read attribute EPOCH_S Max Value"
command: "readAttribute"
attribute: "epoch_s"
response:
value: 4294967295

- label: "Write attribute EPOCH_S Min Value"
command: "writeAttribute"
attribute: "epoch_s"
arguments:
value: 0

- label: "Read attribute EPOCH_S Min Value"
command: "readAttribute"
attribute: "epoch_s"
response:
value: 0

# Tests for Unsupported attribute

- label: "Read attribute UNSUPPORTED"
Expand Down
2 changes: 2 additions & 0 deletions src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ EmberAfAttributeType BaseType(EmberAfAttributeType type)
case ZCL_STATUS_ATTRIBUTE_TYPE: // Status Code
case ZCL_DATA_VER_ATTRIBUTE_TYPE: // Data Version
case ZCL_BITMAP32_ATTRIBUTE_TYPE: // 32-bit bitmap
case ZCL_EPOCH_S_ATTRIBUTE_TYPE: // Epoch Seconds
static_assert(std::is_same<chip::ClusterId, uint32_t>::value,
"chip::Cluster is expected to be uint32_t, change this when necessary");
static_assert(std::is_same<chip::AttributeId, uint32_t>::value,
Expand All @@ -116,6 +117,7 @@ EmberAfAttributeType BaseType(EmberAfAttributeType type)
case ZCL_FABRIC_ID_ATTRIBUTE_TYPE: // Fabric Id
case ZCL_NODE_ID_ATTRIBUTE_TYPE: // Node Id
case ZCL_BITMAP64_ATTRIBUTE_TYPE: // 64-bit bitmap
case ZCL_EPOCH_US_ATTRIBUTE_TYPE: // Epoch Microseconds
static_assert(std::is_same<chip::EventNumber, uint64_t>::value,
"chip::EventNumber is expected to be uint64_t, change this when necessary");
static_assert(std::is_same<chip::FabricId, uint64_t>::value,
Expand Down
4 changes: 4 additions & 0 deletions src/app/zap-templates/common/override.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ function atomicType(arg)
return 'chip::Percent';
case 'percent100ths':
return 'chip::Percent100ths';
case 'epoch_us':
return 'uint64_t';
case 'epoch_s':
return 'uint32_t';
default:
throw 'not overriding';
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/zap-templates/zcl/data-model/chip/test-cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ limitations under the License.
<attribute side="server" code="0x001D" define="LONG_OCTET_STRING" type="LONG_OCTET_STRING" length="1000" writable="true" optional="false">long_octet_string</attribute>
<attribute side="server" code="0x001E" define="CHAR_STRING" type="CHAR_STRING" length="10" writable="true" optional="false">char_string</attribute>
<attribute side="server" code="0x001F" define="LONG_CHAR_STRING" type="LONG_CHAR_STRING" length="1000" writable="true" optional="false">long_char_string</attribute>
<attribute side="server" code="0x0020" define="EPOCH_US" type="EPOCH_US" writable="true" optional="false">epoch_us</attribute>
<attribute side="server" code="0x0021" define="EPOCH_S" type="EPOCH_S" writable="true" optional="false">epoch_s</attribute>

<!-- This attribute should not be enabled on the server side -->
<attribute side="server" code="0x00FF" define="UNSUPPORTED" type="BOOLEAN" writable="true" optional="false">unsupported</attribute>
Expand Down
33 changes: 32 additions & 1 deletion src/controller/data_model/controller-clusters.zap
Original file line number Diff line number Diff line change
Expand Up @@ -9724,6 +9724,36 @@
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "epoch_us",
"code": 32,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "epoch_s",
"code": 33,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "unsupported",
"code": 255,
Expand Down Expand Up @@ -10137,5 +10167,6 @@
"endpointVersion": null,
"deviceIdentifier": null
}
]
],
"log": []
}
150 changes: 150 additions & 0 deletions src/controller/java/zap-generated/CHIPClusters-JNI.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e9ec676

Please sign in to comment.